Code to Predict User Attributes

  1. Create a SimpleList object and populate it with the properties to predict.

    Dim slPropertiesToPredict
    Set slPropertiesToPredict = Server.CreateObject("Commerce.SimpleList")
    
    slPropertiesToPredict.Add("Age")
    slPropertiesToPredict.Add("Education")
    
  2. Create Variant Safearrays to store the predicted properties and values.

    Dim vsavPredictedProps
    Dim vsavPredictedValues
    
  3. Make the predictions, using the dictionary, dCurrentCase, created and populated with information on the current user in Code to Predict Products, the PredictorClient object, oPredictorClient, created in Code to Load a Model and Set Default Properties, and the Purchase1 model loaded in the same section.

    oPredictorClient.Predict dCurrentCase, slPropertiesToPredict _
     vsavPredictedProps, vsavPredictedValues
    
  4. Iterate through the returned predictions.

    Dim i
    For i = LBound(vsavPredictedProps) To UBound(vsavPredictedProps)
    Response.Write vsavPredictedProps(i) & " = " _
     & vsavPredictedValues(i) & "<BR>"
    Next
    
  5. Release the objects.

    Set dCurrentCase = Nothing
    Set slPropertiesToPredict = Nothing
    

Copyright © 2005 Microsoft Corporation.
All rights reserved.