Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
SQL Server 2012 Tutorials - Analysis Services Data Mining.pdf
Скачиваний:
38
Добавлен:
26.03.2016
Размер:
1.41 Mб
Скачать

2.Copy the generic example of the ALTER MINING STRUCTURE statement into the blank query.

3.Replace the following:

<mining structure name> with:

[Bike Buyer]

4. Replace the following:

<mining model> with:

Clustering Model

5. Delete the following:

(

[<key column>], <mining model columns>,

)

6. Replace the following:

USING <algorithm name>( <algorithm parameters> ) with:

USING Microsoft_Clustering

The complete statement should now be as follows:

ALTER MINING STRUCTURE [Bike Buyer] ADD MINING MODEL [Clustering] USING Microsoft_Clustering

7.On the File menu, click Save DMXQuery1.dmx As.

8.In the Save As dialog box, browse to the appropriate folder, and name the file

Clustering_Model.dmx.

9.On the toolbar, click the Execute button.

In the next lesson, you will process the models and the mining structure.

Next Lesson

Lesson 3: Processing the Predictive Mining Structure

Lesson 3: Processing the Bike Buyer Mining Structure

In this lesson, you will use the INSERT INTO statement and the vTargetMail view from the sample database to process the mining structures and mining models that you created in

158

Lesson 1: Creating the Predictive Mining Structure and Lesson 2: Adding Mining Models to the Predictive 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 choose. 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 need to reprocess a mining structure only 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.

Train Structure Template

In order to train the 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

The following is a generic example of the INSERT INTO statement:

INSERT INTO MINING STRUCTURE [<mining structure name>]

(

<mining structure columns>

)

OPENQUERY([<datasource>],'<SELECT statement>')

The first line of the code identifies the mining structure that you will train:

INSERT INTO MINING STRUCTURE [<mining structure name>]

The next line of the code specifies 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.

(

<mining structure columns>

)

The final line of the code defines the data that will be used to train the mining structure:

OPENQUERY([<datasource>],'<SELECT statement>')

159

In this lesson, you use OPENQUERY to define the source data. For information about other methods of defining the source query, see <source data query>.

Lesson Tasks

You will perform the following task in this lesson:

• Process the Bike Buyer mining structure

Processing the Predictive 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 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 name>] with:

Bike Buyer

4. Replace the following:

<mining structure columns> with:

[Customer Key], [Age],

[Bike Buyer], [Commute Distance], [Education], [Gender],

[House Owner Flag],

[Marital Status], [Number Cars Owned],

[Number Children At Home], [Occupation],

[Region],

[Total Children],

[Yearly Income]

5. Replace the following:

OPENQUERY([<datasource>],'<SELECT statement>')

160

with:

OPENQUERY([Adventure Works DW], 'SELECT CustomerKey, Age, BikeBuyer,

CommuteDistance,EnglishEducation,

Gender,HouseOwnerFlag,MaritalStatus,

NumberCarsOwned,NumberChildrenAtHome,

EnglishOccupation,Region,TotalChildren, YearlyIncome

FROM dbo.vTargetMail')

The OPENQUERY statement references the Adventure Works DW Multidimensional 2012 data source to access the view vTargetMail. The view contains the source data that will be used to train the mining models.

The complete statement should now be as follows:

INSERT INTO MINING STRUCTURE [Bike Buyer]

(

[Customer Key], [Age],

[Bike Buyer], [Commute Distance], [Education], [Gender],

[House Owner Flag],

[Marital Status], [Number Cars Owned],

[Number Children At Home], [Occupation],

[Region],

[Total Children],

[Yearly Income]

)

OPENQUERY([Adventure Works DW], 'SELECT CustomerKey, Age, BikeBuyer,

CommuteDistance,EnglishEducation,

Gender,HouseOwnerFlag,MaritalStatus,

161

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]