MicroStrategy ONE
Market Basket Analysis (Using Association Rules Analysis)
Market basket analysis studies retail purchases to determine which items tend to appear together in individual transactions. Retailers use market basket analysis for their commercial websites to suggest additional items to purchase before a customer completes their order.
An example of using market basket analysis for grocery store transactions is described in Creating a Predictive Model Using MicroStrategy.
The MicroStrategy Tutorial project includes an example of a market basket analysis scenario. The example analyzes customer orders of movies, and recommends other movies based on their selections. These recommendations are based on the other customer orders and are meant to provide customers with additional movie options that they are most likely to add to their order. The resulting movie recommendations are provided in the report 3 -- Movie Recommendations
shown below.
The example Tutorial project includes reports, metrics, and other objects created for this market basket analysis example (search the project for "Association Rules"). You can use the objects in the Tutorial project to step through the example and determine how it can be applied to your reporting environment.
The steps below show you how to create similar market basket analysis of movie purchases, using data mining services techniques, in the Tutorial project.
To Create a Training Metric for Market Basket Analysis
The steps below can be used to create the training metric Training Metric for 'Movie Recommendation'
, which is provided with the Tutorial project.
- In MicroStrategy Developer, choose Tools > Training Metric Wizard.
- Click Next.
- Select Association as the type of analysis. The following additional options are displayed and should be defined as explained below:
- Maximum number of items per antecedent: Type
3
for this option. - Minimum confidence: Type
.1
for this option. - Minimum support: Type
.1
for this option. - Click Next.
- Browse to the Order metric, which is stored in
Tutorial\Public Objects\Reports\MicroStrategy Platform Capabilities\MicroStrategy Data Mining Services\Support Objects
. Select the Order metric and click the arrow next to Transaction metric.The Order metric's definition is
Max<FactID=Revenue>(Order){~}
, which is based on the Order attribute. The parameter<FactID=Revenue>
is included to ensure the attribute information can be joined together and displayed on a report. - In the same folder, select the Item metric and click the arrow next to Item metric.
The Item metric's definition is
Max<FactID=Revenue>(Item@DESC){~}
, which is based on the Item attribute. The parameter<FactID=Revenue>
is included to ensure the attribute information can be joined together and displayed on a report. - Click Next.
- Click ... (browse button) for the Folder option to select a folder to save the training metric to.
- Clear the Include extended statistical analysis with the model check box.
- Click Rules.
- For the Return the top ranked rules up to this amount option, change the value to
3
, which returns the top three movie recommendations based on the movies in a customer's order. - Click OK.
- In the Predictive metric(s) to generate area, make the following changes:
- Keep the Rule predictor type selected. For the Name field, type
Movie Recommendation Rule
. - Select the Consequent predictor type. For the Name field, type
Recommendation
. - Click Next.
- Click Finish. The Save As dialog box opens.
- In the Object name field, enter
Training Metric for 'Movie Recommendation'
, and click Save.
After creating a training metric, you must create a report that includes the new training metric.
In addition to the training metric, this report must include the Order and Item attributes, which display the items that were included in each order. A simple filter of Category = Movies
is added to ensure that only movies are included in the report.
Additionally, since there are a large number of orders, another filter is required to reduce the result set. This ensures that the report can be executed in a reasonable amount of time, while also providing enough data to provide relevant market basket analysis of the order information. The report 2 -- Movie Basket Analysis Training
, available with the MicroStrategy Tutorial project, includes a filter that prompts the user for which orders to return. In the results shown below, every seventh order is displayed.
The steps below show you how to create a similar training report in the Tutorial project.
To Create a Training Report for Market Basket Analysis
- In MicroStrategy Developer, choose File > New > Report.
- From the General tab, select Blank Report, and click OK.
- Add the Order and Item attributes to the rows of the report.
- Add the training metric you created using the steps To Create a Training Metric for Market Basket Analysis to the columns of the report.
- In the Report Filter pane, drag and drop the Category attribute to begin creating a new filter qualification. Options to create an attribute qualification are displayed.
- Click Add.
- In the Available objects pane, select Movies, and click the arrow to move it to the Selected objects pane.
- Click OK.
- Click OK.
To Limit the Number of Orders Included in the Market Basket Analysis
Next you need to create a filter to limit the number of orders returned for the report. The example report 2 -- Movie Basket Analysis Training
uses the filter n-th Order Sample
. You can add this filter to limit the number of orders returned, or you can use the steps below to create a simple filter that includes a subset of elements from the Order attribute. The rest of this example assumes that you create the simple filter detailed below.
- In the Report Filter pane, drag and drop the Order attribute to begin creating a new filter qualification.
- Click Add.
- In the Available objects pane, select Order elements from ID 10,000 to 12,000, and click the arrow to move the elements to the Selected objects pane. You can only select 1,000 elements at a time, so you need to do multiple selections to include all these elements in the Selected objects pane.
- Click OK.
- Click OK.
To Save the Report and Create the Predictive Analysis Metrics
- Choose File > Save As.
- In the Object name field, enter
Market Basket Analysis Report
, and click Save. -
Click the Run Report icon. The report execution begins.
Depending on your system resources, the report execution can take a considerable amount of time, as various data mining calculations are being performed to return the market basket analysis. Once the report execution is complete, a message is displayed that verifies that predictive metrics were created.
The following predictive metrics are created by executing the report:
- Three predictive metrics are created to explain the market basket rules. These show the movie items included in an order, and the associated movie items that are recommended based on order item. These metrics show the top three recommendations from highest confidence to lowest confidence:
Movie Recommendation Rule(confidence,1)
Movie Recommendation Rule(confidence,2)
Movie Recommendation Rule(confidence,3)
- Three predictive metrics are created to list only the recommended movie, based on the movie items included in an order. These metrics show the top three recommendations from highest confidence to lowest confidence:
Recommendation(confidence,1)
Recommendation(confidence,2)
Recommendation(confidence,3)
To view these market basket analysis recommendations, you can include them on a report. You can use the same report you created using the steps To Create a Training Report for Market Basket Analysis.
The steps below show you how to create a report in the Tutorial project, similar to the example report
3 -- Movie Recommendations
.
To View the Market Basket Analysis Predictive Metrics
- Open the report you created using the steps To Create a Training Report for Market Basket Analysis.
- Right-click the training metric
Training Metric for 'Movie Recommendation'
and select Remove From Report. -
Double-click the filter qualification on Order to modify it. Remove the Order elements with IDs 10,501 to 12,000. This should leave just the Order elements with IDs 10,000 to 10,500 in the filter qualification. Click OK to accept the changes and return to the report.
This step is done to reduce the number of results to return and analyze. Returning fewer results allows the report to return results quicker while still providing market basket analysis. You can include other subsets of Order elements to evaluate other orders.
- Click the Run Report icon. The report is executed.
The report displays both the rules that determine which movies are recommended, as well as just the recommendations themselves. To make the report easier to read, you can remove the
Movie Recommendation Rule(confidence,1)
,Movie Recommendation Rule(confidence,2)
, andMovie Recommendation Rule(confidence,3)
metrics from the report. This leaves just the metrics that display the three movies recommended to a customer to add to their order, as shown in the report below.The report shown above shows a simple display of movie recommendations based on the order of other movie items. These market basket techniques can be used to make recommendations to customers about any items they are likely to add to their order at purchase time.
The steps below show you how to include a prompted filter on this report so that an order or a group of orders can be selected for on the fly recommendations.
To Include a Prompt on the Report to Provide on the Fly Recommendations
- Once you have viewed the results of the report created using the steps To View the Market Basket Analysis Predictive Metrics, choose View in the Report Editor > Design View.
- In the Report Filter pane, double-click the filter qualification on the Order attribute elements.
- Click Prompt.
- In the Attribute field, the Order attribute should already be selected. Click Next.
- Keep the default option of List all elements (no restriction) selected. Click Next.
- Within the Prompt restrictions area, make the following changes:
- Select the Minimum number of answer check box. Increase the value to
1
. - Select the Maximum number of answers check box. Increase the value to the number of orders you want to limit the report to. For example, you can set the maximum to
10
, so that the report displays only 10 orders at a time. - Select the Prompt answer required check box.
- Click Next.
- In the Select default prompt answers area, click Clear.
This will require the person using the report to decide what orders they want to return movie recommendations for, rather than simply returning recommendations for some default orders.
- Click Finish.
- Click OK.
- Click the Run Report icon.
- The prompt appears. Make a selection of orders to return recommendations for based on the earlier market basket analysis.
For example, select orders 13,000 through 13,009 and click the arrow icon to include those orders in the report.
- Click Finish.
The report is executed, which displays movie recommendations for the selected orders, as shown below.
This simple prompted report can be the beginning of a recommendation engine that provides recommendations to customers based on market basket analysis techniques.