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.
Predictor.InitPredictor(DSN, Table, UserColumn, SKUColumn, QuantityColumn, MaxMemory)
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 |
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
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.