Code to Classify a User
This code sample will first determine the most likely segment to which the current user belongs, and then iterate the probabilities associated with the membership of the user in each segment.
Using the PredictorClient object, oPredictorClient, created in Code to Load a Model and Set Default Properties, and the connection string, sDWConnect, retrieved in Code to Retrieve the Database Connection String, load the Demog1 model created in Predictor Schema Example.
oPredictorClient.LoadModelFromDB "Demog1", sDWConnect
Using the dictionary, dCurrentCase, created in Code to Predict User Attributes, predict the most likely segment.
Dim sMostLikelySegment Dim vProbability sMostLikelySegment = oPredictorClient.PredictMostLikelySegment _ dCurrentCase, vProbability Response.Write "Most likely segment is " & sMostLikelySegment & "<BR>" Response.Write "The probability of membership in this segment is " _ & vProbability & "<P>"
Create Variant Safearrays to store the segment names and associated membership probabilities.
Dim vsavSegmentNames Dim vsavProbabilities
Make the predictions.
oPredictorClient.PredictAllSegments dCurrentCase, vsavSegmentNames _ vsavProbabilities
Iterate through the returned predictions.
Dim i For i = LBound(vsavSegmentNames) To UBound(vsavSegmentNames) Response.Write vsavSegmentNames(i) & " - " _ & vsavProbabilities(i) & "<BR>" Next
Copyright © 2005 Microsoft Corporation.
All rights reserved.