- •Contents
- •Data Mining Tutorials (Analysis Services)
- •Basic Data Mining Tutorial
- •Lesson 1: Preparing the Analysis Services Database (Basic Data Mining Tutorial)
- •Creating an Analysis Services Project (Basic Data Mining Tutorial)
- •Creating a Data Source (Basic Data Mining Tutorial)
- •Creating a Data Source View (Basic Data Mining Tutorial)
- •Lesson 2: Building a Targeted Mailing Structure (Basic Data Mining Tutorial)
- •Creating a Targeted Mailing Mining Model Structure (Basic Data Mining Tutorial)
- •Specifying the Data Type and Content Type (Basic Data Mining Tutorial)
- •Specifying a Testing Data Set for the Structure (Basic Data Mining Tutorial)
- •Lesson 3: Adding and Processing Models
- •Adding New Models to the Targeted Mailing Structure (Basic Data Mining Tutorial)
- •Processing Models in the Targeted Mailing Structure (Basic Data Mining Tutorial)
- •Lesson 4: Exploring the Targeted Mailing Models (Basic Data Mining Tutorial)
- •Exploring the Decision Tree Model (Basic Data Mining Tutorial)
- •Exploring the Clustering Model (Basic Data Mining Tutorial)
- •Exploring the Naive Bayes Model (Basic Data Mining Tutorial)
- •Lesson 5: Testing Models (Basic Data Mining Tutorial)
- •Testing Accuracy with Lift Charts (Basic Data Mining Tutorial)
- •Testing a Filtered Model (Basic Data Mining Tutorial)
- •Lesson 6: Creating and Working with Predictions (Basic Data Mining Tutorial)
- •Creating Predictions (Basic Data Mining Tutorial)
- •Using Drillthrough on Structure Data (Basic Data Mining Tutorial)
- •Lesson 1: Creating the Intermediate Data Mining Solution (Intermediate Data Mining Tutorial)
- •Creating a Solution and Data Source (Intermediate Data Mining Tutorial)
- •Lesson 2: Building a Forecasting Scenario (Intermediate Data Mining Tutorial)
- •Adding a Data Source View for Forecasting (Intermediate Data Mining Tutorial)
- •Creating a Forecasting Structure and Model (Intermediate Data Mining Tutorial)
- •Modifying the Forecasting Structure (Intermediate Data Mining Tutorial)
- •Customizing and Processing the Forecasting Model (Intermediate Data Mining Tutorial)
- •Exploring the Forecasting Model (Intermediate Data Mining Tutorial)
- •Creating Time Series Predictions (Intermediate Data Mining Tutorial)
- •Advanced Time Series Predictions (Intermediate Data Mining Tutorial)
- •Lesson 3: Building a Market Basket Scenario (Intermediate Data Mining Tutorial)
- •Adding a Data Source View with Nested Tables (Intermediate Data Mining Tutorial)
- •Creating a Market Basket Structure and Model (Intermediate Data Mining Tutorial)
- •Modifying and Processing the Market Basket Model (Intermediate Data Mining Tutorial)
- •Exploring the Market Basket Models (Intermediate Data Mining Tutorial)
- •Filtering a Nested Table in a Mining Model (Intermediate Data Mining Tutorial)
- •Predicting Associations (Intermediate Data Mining Tutorial)
- •Lesson 4: Building a Sequence Clustering Scenario (Intermediate Data Mining Tutorial)
- •Creating a Sequence Clustering Mining Model Structure (Intermediate Data Mining Tutorial)
- •Processing the Sequence Clustering Model
- •Exploring the Sequence Clustering Model (Intermediate Data Mining Tutorial)
- •Creating a Related Sequence Clustering Model (Intermediate Data Mining Tutorial)
- •Creating Predictions on a Sequence Clustering Model (Intermediate Data Mining Tutorial)
- •Lesson 5: Building Neural Network and Logistic Regression Models (Intermediate Data Mining Tutorial)
- •Adding a Data Source View for Call Center Data (Intermediate Data Mining Tutorial)
- •Creating a Neural Network Structure and Model (Intermediate Data Mining Tutorial)
- •Exploring the Call Center Model (Intermediate Data Mining Tutorial)
- •Adding a Logistic Regression Model to the Call Center Structure (Intermediate Data Mining Tutorial)
- •Creating Predictions for the Call Center Models (Intermediate Data Mining Tutorial)
- •Creating and Querying Data Mining Models with DMX: Tutorials (Analysis Services - Data Mining)
- •Bike Buyer DMX Tutorial
- •Lesson 1: Creating the Bike Buyer Mining Structure
- •Lesson 2: Adding Mining Models to the Bike Buyer Mining Structure
- •Lesson 3: Processing the Bike Buyer Mining Structure
- •Lesson 4: Browsing the Bike Buyer Mining Models
- •Lesson 5: Executing Prediction Queries
- •Market Basket DMX Tutorial
- •Lesson 1: Creating the Market Basket Mining Structure
- •Lesson 2: Adding Mining Models to the Market Basket Mining Structure
- •Lesson 3: Processing the Market Basket Mining Structure
- •Lesson 4: Executing Market Basket Predictions
- •Time Series Prediction DMX Tutorial
- •Lesson 1: Creating a Time Series Mining Model and Mining Structure
- •Lesson 2: Adding Mining Models to the Time Series Mining Structure
- •Lesson 3: Processing the Time Series Structure and Models
- •Lesson 4: Creating Time Series Predictions Using DMX
- •Lesson 5: Extending the Time Series Model
Lesson 3: Processing the Market Basket Mining Structure
In this lesson, you will use the INSERT INTO statement and the vAssocSeqLineItems and vAssocSeqOrders from the sample database to process the mining structures and mining models that you created in Lesson 1: Creating the Association Mining Structure and Lesson 2: Adding Mining Models to the Association Mining Structure.
When you process a mining structure, Analysis Services reads the source data and builds the structures that support mining models. When you process a mining model, the data defined by the mining structure is passed through the data mining algorithm that you chose. The algorithm searches for trends and patterns, and then stores this information in the mining model. The mining model, therefore, does not contain the actual source data, but instead contains the information that was discovered by the algorithm. For more information about processing mining models, see Processing Data Mining Objects.
You only have to reprocess a mining structure if you change a structure column or change the source data. If you add a mining model to a mining structure that has already been processed, you can use the INSERT INTO MINING MODEL statement to train the new mining model on the existing data.
Because the Market Basket mining structure contains a nested table, you will have to define the mining columns to be trained using the nested table structure, and use the SHAPE command to define the queries that pull the training data from the source tables.
INSERT INTO Statement
In order to train the Market Basket mining structure and its associated mining models, use the INSERT INTO (DMX) statement. The code in the statement can be broken into the following parts.
•Identifying the mining structure
•Listing the columns in the mining structure
•Defining the training data using SHAPE
The following is a generic example of the INSERT INTO statement:
INSERT INTO MINING STRUCTURE [<mining structure name>]
(
<mining structure columns> [<nested table>]
( SKIP, <skipped column> )
)
SHAPE {
OPENQUERY([<datasource>],'<SELECT statement>') } APPEND
(
185
{OPENQUERY([<datasource>],'<nested SELECT statement>')
}
RELATE [<case key>] TO [<foreign key>] ) AS [<nested table>]
The first line of the code identifies the mining structure that you will train:
INSERT INTO MINING STRUCTURE [<mining structure name>]
The next lines of the code specify the columns that are defined by the mining structure. You must list each column in the mining structure, and each column must map to a column contained within the source query data. You can use SKIP to ignore columns that exist in the source data but do not exist in the mining structure. For more information about how to use SKIP, see INSERT INTO (DMX).
(
<mining structure columns> [<nested table>]
( SKIP, <skipped column> )
)
The final lines of the code define the data that will be used to train the mining structure. Because the source data is contained within two tables, you will use SHAPE to relate the tables.
SHAPE {
OPENQUERY([<datasource>],'<SELECT statement>') } APPEND
(
{OPENQUERY([<datasource>],''<nested SELECT statement>'')
}
RELATE [<case key>] TO [<foreign key>] ) AS [<nested table>]
In this lesson, you use OPENQUERY to define the source data. For information about other methods of defining a query on the source data, see <source data query>.
Lesson Tasks
You will perform the following task in this lesson:
• Process the Market Basket mining structure
Processing the Market Basket Mining Structure
To process the mining structure by using INSERT INTO
1. In Object Explorer, right-click the instance of Analysis Services, point to New
186
Query, and then click DMX.
Query Editor opens and contains a new, blank query.
2.Copy the generic example of the INSERT INTO statement into the blank query.
3.Replace the following:
[<mining structure>] with:
Market Basket
4. Replace the following:
<mining structure columns> [<nested table>]
( SKIP, <skipped column> )
with:
[OrderNumber],
[Products] (SKIP, [Model])
In the statement, Products refers to the Products table defined by the SHAPE statement. SKIP is used to ignore the Model column, which exists in the source data as a key, but is not used by the mining structure.
5. Replace the following:
SHAPE {
OPENQUERY([<datasource>],'<SELECT statement>') } APPEND
(
{OPENQUERY([<datasource>],'<nested SELECT statement>')
}
RELATE [<case key>] TO [<foreign key>] ) AS [<nested table>]
with:
SHAPE {
OPENQUERY([Adventure Works DW],'SELECT OrderNumber FROM vAssocSeqOrders ORDER BY OrderNumber')}
APPEND
(
{OPENQUERY([Adventure Works DW],'SELECT OrderNumber, Model
187
FROM
dbo.vAssocSeqLineItems ORDER BY OrderNumber, Model')
}
RELATE OrderNumber to OrderNumber ) AS [Products]
The source query references the |
data source defined in the |
sample |
project. It uses this data source to access the vAssocSeqLineItems and |
|
vAssocSeqOrders views. These views contain the source data that will be used to train the mining model. If you have not created this project or these views, see Basic Data Mining Tutorial.
Within the SHAPE command, you will use OPENQUERY to define two queries. The first query defines the parent table, and the second query defines the nested table. The two tables are related using the OrderNumber column, which exists in both tables.
The complete statement should now be as follows:
INSERT INTO MINING STRUCTURE [Market Basket]
(
[OrderNumber],[Products] (SKIP, [Model])
)
SHAPE {
OPENQUERY([Adventure Works DW],'SELECT OrderNumber FROM vAssocSeqOrders ORDER BY OrderNumber')}
APPEND
(
{OPENQUERY([Adventure Works DW],'SELECT OrderNumber, Model FROM
dbo.vAssocSeqLineItems ORDER BY OrderNumber, Model')
}
RELATE OrderNumber to OrderNumber ) AS [Products]
6.On the File menu, click Save DMXQuery1.dmx As.
7.In the Save As dialog box, browse to the appropriate folder, and name the file
Process Market Basket.dmx.
8.On the toolbar, click the Execute button.
After the query has finished running, you can view the patterns and itemsets that were found, view associations, or filter by itemset, probability, or importance. To view this
188