Previous in Contents Next in Contents

Predictor Object Overview

The Predictor object is usually created in the Global.asa file. Use the Active Server Pages (ASP) Server object's CreateObject method to create a Predictor object, as follows:

REM -- Create the predictive cross selling engine
set MSCSPredictor = Server.CreateObject("Commerce.Predictor")

Also in Global.asa, store the new object in the Application object, as follows:

Set Application("MSCSPredictor")    = MSCSPredictor

The Predictor object depends on two resources in order to model its predictions:

Site Purchase History

The site purchase history is a database table of previous purchases by all customers at the site. The site purchase history provides the raw data that is input to the Predictor by means of the InitPredictor method. The InitPredictor method processes this input to produce a knowledge base.

The site purchase history must contain, at minimum, the shopper ID, the SKU, and the quantity for each item purchased. Preferably, it also contains the date, enabling an administrator to remove outdated records.

The site purchase history is updated for each item in the basket that is purchased by the SQLItemADO pipeline component in the Accept stage of the pipeline, which runs a query defined in the site's query map as follows:

MSCSQueryMap.insert_predictor_data.SQLCommand = "insert into mspress30_predictor_data values (?, ?, ?, {fn CurDate()})"

In building the knowledge base, the Predictor object processes all purchased items listed in the site purchase history. The resulting knowledge base is organized by shopper ID, so that it consists of merged baskets that each contain all the items ever purchased by each customer, as long as the orders are still included in the site purchase history. Because information is collected for specific customers even when the items are purchased at different times, the knowledge base contains more complete customer preference patterns.

Customer Interest List

The customer interest list is a list of items in which the current customer has already ordered or expressed interest. Usually, this list contains the contents of the customer's shopping basket, but it can also contain products the customer has requested information on, or purchased in the past.

In the page in which you want the suggested cross promotional items to appear, use scripting to pass the customer interest list as an argument to the GetPredictions method. This method then returns a list of additional items to suggest to the customer, based on the customer interest list and purchasing patterns. Your page then displays the suggested items to the customer.

The customer interest list is implemented as a SimpleList object that contains Dictionary objects, where each Dictionary object represents an item and contains properties representing the SKU and quantity for each item.

The GetPredictions method excludes any items that are in the customer interest list from the returned list of suggestions. For products (such as books) that customers tend to purchase only once, you can submit as the customer interest list not just the customer's current basket, but a merged collection of all items that customer has ever purchased, using data from the receipts table. Not only will this generate a more accurate list of recommendations, it will also prevent the list of recommendations from including books the shopper has previously purchased.

Maintaining the Site Purchase History

As purchases are made, they are added to the site purchase history. However, Predictor component is not affected by changes to the site purchase history until the InitPredictor method is called.

Note  Reinvoke the InitPredictor method as the mix of relevant products and relevant user purchase patterns change. Usually, the initialization should be invoked at least once a week, and possibly more often depending on the application.

The following additional suggestions will help to ensure optimal results when using the Predictor object:

Note  The Predictor object works with Microsoft® SQL Server™ or Oracle databases. It does not work with Microsoft® Access databases.

Examples

The following two topics illustrate the use of the Predictor object, using example code from the Microsoft® Press starter site:


© 1997-2000 Microsoft Corporation. All rights reserved.