Creating Predictions (Data Mining Tutorial)

After you have tested the accuracy of your mining models and decided that you are satisfied with them, you can create Data Mining Extensions (DMX) prediction queries by using Prediction Query Builder on the Mining Model Prediction tab in Data Mining Designer. Prediction Query Builder is similar to Access Query Builder; you use drag-and-drop operations to build the queries. Prediction Query Builder contains the following views:

  • Design
  • Query
  • Result

With the Design and Query views, you can build and examine your query. You can then run the query and view the results in the Result view.

For more information about how to use Prediction Query Builder, see Creating DMX Prediction Queries.

Creating the Query

The first step in creating a prediction query is to select a mining model and input table.

To select a model and input table

  1. On the Mining Model Prediction tab of Data Mining Designer, in the Mining Model box, click Select Model.

    The Select Mining Model dialog box opens.

  2. Navigate through the tree to the Targeted Mailing structure, expand the structure, select TM_Decision_Tree, and then click OK.

  3. In the Select Input Table(s) box, click Select Case Table.

    The Select Table dialog box opens.

  4. In the Data Source list, verify that Adventure Works DW is selected.

  5. In Table/View Name, select the ProspectiveBuyer table, and then click OK.

After you select the input table, Prediction Query Builder creates a default mapping between the mining model and the input table, based on the names of the columns.

To build the prediction query

  1. In the Source column in the grid on the Mining Model Prediction tab, click the cell in the first empty row, and then select ProspectiveBuyer .

  2. In the ProspectiveBuyer row, in the Field column, verify that ProspectAlternateKey is selected.

    This adds the unique identifier to the prediction query so that you can identify who is likely to buy a bicycle, and who is not likely to buy a bicycle.

  3. Click the next empty row in the Source column, and then select TM_Decision_Tree.

  4. In the TM_Decision_Tree row, in the Field column, verify that Bike Buyer is selected.

    This specifies that the Microsoft Decision Tree model in the targeted mailing structure will be used to create the predictions.

  5. Click the next empty row under the Source column, and then select Prediction Function.

  6. In the Prediction Function row, in the Field column, select PredictProbability.

    Prediction functions provide information about how the model predicts. The PredictProbability function provides information about the probability of the prediction being correct. You can specify parameters for the prediction function in the Criteria/Argument column.

  7. In the PredictProbability row, in the Criteria/Argument column, type [TM_Decision_Tree].[Bike Buyer].

    This specifies the target column for the PredictProbability function. For more information about functions, see Data Mining Extensions (DMX) Function Reference.

  8. Click Switch to query result view, which is the first button on the toolbar of the Mining Model Prediction tab.

    The following table shows a portion of the results that are returned. These results show that the customer with ID 827 is likely to buy a bike, and the probability of the prediction being correct is 63%.

ProspectAlternateKey BikeBuyer Expression

827

1

0.633836…

833

0

0.521134…

844

0

0.735697…

Viewing the Results

The ProspectAlternateKey, BikeBuyer, and Expression columns identify potential customers, indicate whether the potential customers are bike buyers, and indicate the probability of the prediction being correct. You can use these results to determine which potential customers you should target for the mailing.

The first button on the toolbar of the Mining Model Prediction tab lets you switch between three views. When you click Switch to query result view, you see the results of the current prediction query. If you are viewing results, you can click Switch to query design view to go back to the grid and change the query..

If you switch to the Query view, you can view and modify the DMX code that Prediction Query Builder created. You can also run the query, modify the query, and run the modified query. For example, to view only the customers who are predicted to buy bikes, and to sort them by order of descending probability, you can add the following statements at the end of the DMX query:

WHERE [Bike Buyer] = 1
ORDER BY PredictProbability([TM_Decision_Tree].[Bike Buyer]) DESC

You can switch back and forth between Query view and Results view; however, if you switch back to the Design view, the modified query is not persisted.

Next Lesson

Lesson 3: Building the Forecasting Scenario

See Also

Other Resources

How to: Create a Prediction Query
Using the Prediction Query Builder to Create DMX Prediction Queries

Help and Information

Getting SQL Server 2005 Assistance