Step 6: Modify the Site to Create a PredictorClient Object Call

In this step, you modify the pages of your site to call create a PredictorClient object call so you get the model you want.

To modify the site to load the model from a file

  1. Modify the initialization page on the site to create a PredictorClient object and call LoadModelFromFile method, specifying the model you want to use and the local path to the model file.

    Following is a sample of the call on the initialization page on your site:

    ' PredictionModel2.mdl is stored in the working directory of the
    '  calling process
    oPredictorClient.LoadModelFromFile "PredictionModel2.mdl"
    

    For more information, see PredictorClient Object.

  2. Modify pages within the site where you want to show prediction results. Add calls to the PredictorClient API in order to retrieve and display the appropriate results from the model specified.

    Following is a sample of the call on a page of your site:

    ' dCase is a Dictionary object, slPropsToPredict is a SimpleList
    ' vsavPredictedProps, vsavPredictedValues are Variant SafeArrays
    oPredictorClient.Predict dCase, slPropsToPredict, vsavPredictedProps, _
     vsavPredictedVals, 10
    

    For more information, see PredictorClient Object.

To modify the site to load the model from a database

  1. Modify the initialization page on the site to create a PredictorClient object and call LoadModelFromDB method, specifying the model you want to use and the connection string to the external database.

    Following is a sample of the call on the initialization page on your site, using Windows Authentication in the connection string:

    oPredictorClient.LoadModelFromDB "Purchase1", _
     "Provider=SQLOLEDB.1;Integrated Security='SSPI';Persist Security Info=True;Initial Catalog=PredictorDemo_Outside;Data Source=CSSERVER1;Initial Catalog=Retail_dw;" _
    

    For more information, see PredictorClient Object.

  2. Modify pages within the site where you want to show prediction results. Add calls to the PredictorClient API in order to retrieve and display the appropriate results from the model specified.

    Following is a sample of the call on a page of your site:

    ' dCase is a Dictionary object, slPropsToPredict is a SimpleList
    ' vsavPredictedProps, vsavPredictedValues are Variant SafeArrays
    oPredictorClient.Predict dCase, slPropsToPredict, vsavPredictedProps, _
     vsavPredictedVals, 10
    

    For more information, see PredictorClient Object.

Copyright © 2005 Microsoft Corporation.
All rights reserved.