Code to Load a Model and Set Default Properties

This code is placed in the Global.asa file. The properties are set here to avoid having to explicitly set the values for every Predict method call.

  1. Create a PredictorClient object.

    Dim oPredictorClient
    Set oPredictorClient = Server.CreateObject("Commerce.PredictorClient")
    
  2. Using the connection string, sDWConnect, retrieved in Code to Retrieve the Database Connection String, load the Purchase1 model created in Code to Build a New Model.

    oPredictorClient.LoadModelFromDB "Purchase1", sDWConnect
    
  3. Set the properties. The bFailOnUnknownInputAttributes property is set to True while debugging the application. This forces the Predict method to fail when information passed to the method is not recognized by the currently loaded model.

    oPredictorClient.bFailOnUnknownInputAttributes = True
    oPredictorClient.fpDefaultConfidence = 95
    oPredictorClient.fpPopularityPenalty = 0.2
    
  4. Associate the PredictorClient object with the site to allow performance monitoring to be aggregated over the site.

    oPredictorClient.sSiteName = "Retail"
    
  5. Release the object.

    Set oPredictorClient = Nothing
    

Copyright © 2005 Microsoft Corporation.
All rights reserved.