Predictor.InitPredictor Method

The InitPredictor method builds a knowledge base of customer preferences by examining a database table containing the site purchase history. The method merges purchases by shopper ID, creating merged baskets that contain all purchases for each unique customer in the site’s purchase history.

The InitPredictor method returns the total number of merged baskets that it has loaded into the knowledge base. This value may be used to verify that the Predictor object has correctly processed the site purchase history. Also, when used in combination with the number of matches returned by the GetPredictions method, the value can help to determine the validity of a particular suggestion.

Syntax

Predictor.InitPredictor(DSN, Table, UserColumn, SKUColumn, QuantityColumn, MaxMemory)

Parameters

DSN
The data source name (DSN) for the table containing the site purchase history.
Table
The name of the table containing the site purchase history.
UserColumn
The name of the column that contains the shopper ID. This must be a column in Table.
SKUColumn
The name of the column that contains the SKU of the item(s) ordered. This must be a column in Table.
QuantityColumn
The name of the column that contains the quantity of items ordered. This must be a column in Table.
MaxMemory
The maximum amount of memory, in kilobytes (K), to allocate to the knowledge base. This setting must be at least 1000 (1 megabyte (MB) of memory). A recommended size is 4000 (indicating that a maximum of 4 MB of RAM could be used by the object). The object uses this limit in determining which baskets (sets of SKUs associated with a single customer) to sample for its analysis. If the MaxMemory parameter is less than the amount needed to store a complete knowledge base, priority is given to those merged baskets containing the most items. (Baskets are merged for all purchases with the same shopper ID in the site purchase history.)

Additional memory generally improves performance. Because the quality of recommendations increases significantly with the size of the sample that the Predictor object can accommodate, higher settings of this parameter are recommended. This parameter sets the limit of memory used. The Predictor object does not necessarily use all the memory specified.

The following table may be used to determine suggested memory sizes (in kilobytes). The table maps the approximate number of unique SKUs appearing in the site’s purchase history (from 100 to 100,000 SKUs) against an estimate of the number of SKUs each individual customer has purchased, based on shopper ID in the site’s purchase history (an average of either 10 or 3 SKUs per basket). The table suggests memory requirements based on average number of baskets per SKU (thickness of the data) between 20 and 50.
Unique SKUs in site purchase history Average SKUs per customer Suggested memory requirement (KB)
100 10 1,000
100 3 1,000
1,000 10 1,100–1,900
1,000 3 1,600–3,100
10,000 10 3,500–7,400
10,000 3 6,000–13,600
20,000 10 6,500–14,200
20,000 3 11,400–26,700
100,000 10 30,300–69,200
100,000 3 55,200–131,500

Example

The following example, from Microsoft Press Global.asa, initializes the knowledge base:

call MSCSPredictor.InitPredictor(MSCSSite.DefaultConnectionString, "mspress30_predictor_data", "shopper_id", "sku", "quantity", 2000)

You can also make use of the value returned as an additional determination of validity. The following example performs the initialization and saves the value returned (the total number of merged baskets loaded into the knowledge base):

Application("predictorBaskets") = MSCSPredictor.InitPredictor(MSCSSite.DefaultConnectionString, "mspress30_predictor_data", "shopper_id", "sku", "quantity", 2000)

Using this value, you can add a test for a reasonable number of baskets to determine whether to call the GetPredictions method:

if Not IsNull(predictor) and Not IsEmpty(predictor)  and 
      Application("predictorBaskets") > 20 then
   set products = predictor.GetPredictions(orderItems, 6, 0.3, 2)
   REM display suggestions

Remarks

The knowledge base is created or updated only by calling the InitPredictor method. If the InitPredictor method is called in Global.asa, then the knowledge base will be updated only when the application is started.

The site purchase history may have any valid name, and its columns may have any valid name, because the InitPredictor method accepts arbitrary names. Furthermore, the columns may appear in any order in the table, and the table may optionally contain other columns as well.


© 1997-1998 Microsoft Corporation. All rights reserved.