Creating Predictions (Basic 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 has three views. 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.
The first step in creating a prediction query is to select a mining model and input table.
To select a model and input table
On the Mining Model Prediction tab of Data Mining Designer, in the Mining Model box, click Select Model.
In the Select Mining Model dialog box, navigate through the tree to the Targeted Mailing structure, expand the structure, select TM_Decision_Tree, and then click OK.
In the Select Input Table(s) box, click Select Case Table.
In the Select Table dialog box, in the Data Source list, select Adventure Works DW2008.
In Table/View Name, select the ProspectiveBuyer (dbo) table, and then click OK.
The ProspectiveBuyer table most closely resembles the vTargetMail case table.
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. At least one column from the structure must match a column in the external data.
The data that you use to determine the accuracy of the models must contain a column that can be mapped to the predictable column.
To map the structure columns to the input table columns
Right-click the lines connecting the Mining Model window to the Select Input Table window, and select Modify Connections.
Notice that not every column is mapped. We will add mappings for several Table Columns.
Under Table Column, click the Bike Buyer cell and select ProspectiveBuyer.Unknown from the dropdown.
This maps the predictable column, [Bike Buyer], to an input table column.
In Solution Explorer, right-click the Targeted Mailing data source view and select View Designer.
Right-click the ProspectiveBuyer table title and select New Named Calculation.
In the Column name box, type calcAge.
In the Expression box, type DATEDIFF(YYYY,[BirthDate],getdate()) and click OK.
The input table has no corresponding Age column. This expression will calculate customer age from the input table BirthDate column. Since Age was identified as the most influential column for predicting bike buying, it must exist in both the model and input table.
In Data Mining Designer, select the Mining Model Prediction tab and re-open the Modify Connections window.
Under Table Column, click the Age cell and select ProspectiveBuyer.calcAge from the dropdown.
To design the prediction query
The first button on the toolbar of the Mining Model Prediction tab is the Switch to design view / Switch to result view / Switch to query view button. Click the down arrow on this button, and select Design.
In the grid on the Mining Model Prediction tab, click the cell in the first empty row in the Source column, and then select Prediction Function.
This specifies the target column for the PredictProbability function. For more information about functions, see Data Mining Extensions (DMX) Function Reference.
In the Prediction Function row, in the Field column, select PredictProbability.
From the Mining Model window above, select and drag [Bike Buyer] into the Criteria/Argument cell.
When you let go, [TM_Decision_Tree].[Bike Buyer] appears in the Criteria/Argument cell.
Click the next empty row in the Source column and then select TM_Decision_Tree.
In the TM_Decision_Tree row, in the Field column, select Bike Buyer.
In the TM_Decision_Tree row, in the Criteria/Argument column, type =1.
Click the next empty row in the Source column and then select ProspectiveBuyer.
In the ProspectiveBuyer row, in the Field column, select ProspectiveBuyerKey.
This adds the unique identifier to the prediction query so that you can identify who is and who is not likely to buy a bicycle
Add five more rows to the grid. Fore each row, select ProspectiveBuyer as the Source and then add the following columns in the Field cells:
Finally, run the query and browse the results.
To run the query and view results
In the Mining Model Prediction tab, select the Result button.
After the query runs and the results are displayed, you can review the results.
The Mining Model Prediction tab displays contact information for potential customers who are likely to be bike buyers. The Expression column indicates the probability of the prediction being correct. You can use these results to determine which potential customers to target for the mailing.
Click the Save button to save the results.