共用方式為


第3課:處理自行車買家採礦結構

在這一課中,您將使用 AdventureWorksDW2012 範例資料庫中的 INSERT INTO 語句和 vTargetMail 檢視,來處理您在第1課:建立自行車購買者採礦結構中建立的採礦結構,以及在第2課:將採礦模型新增至自行車購買者採礦結構中的採礦模型。

當您處理採礦結構時,Analysis Services 會讀取源數據,並建置支援採礦模型的結構。 當您處理採礦模型時,採礦結構所定義的數據會透過您選擇的數據採礦演演算法傳遞。 演算法會搜尋趨勢和模式,然後將此資訊儲存在採礦模型中。 因此,採礦模型不包含實際的源數據,而是包含演算法所探索的資訊。 如需處理採礦模型的詳細資訊,請參閱處理需求和考慮(數據採礦)。

只有在變更結構數據行或變更源數據時,才需要重新處理採礦結構。 如果您將採礦模型新增至已處理的採礦結構,您可以使用 INSERT INTO MINING MODEL 語句來定型新的採礦模型。

列車結構範本

若要將採礦結構及其相關聯的採礦模型定型,請使用 INSERT INTO (DMX) 語句。 語句中的程式代碼可以分成下列部分:

  • 識別採礦結構

  • 列出採礦結構中的欄位

  • 定義訓練數據

以下是 INSERT INTO 語句的泛型範例:

INSERT INTO MINING STRUCTURE [<mining structure name>]  
(  
   <mining structure columns>  
)  
OPENQUERY([<datasource>],'<SELECT statement>')  

程式碼的第一行會識別您將訓練的資料挖掘結構:

INSERT INTO MINING STRUCTURE [<mining structure name>]  

程序代碼的下一行會指定採礦結構所定義的數據行。 您必須列出採礦結構中的每個數據行,而且每個數據行都必須對應至源查詢數據中包含的數據行。

(  
   <mining structure columns>  
)  

程式代碼的最後一行會定義將用來定型採礦結構的數據:

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

在這一課,您會使用 OPENQUERY 來定義源數據。 如需定義來源查詢之其他方法的相關信息,請參閱 <源數據查詢>

課程任務

您將在此課程中執行下列工作:

  • 處理 Bike Buyer 採礦結構

處理預測性採礦結構

使用 INSERT INTO 處理採礦結構

  1. 物件總管 中,以滑鼠右鍵點擊 Analysis Services 實例,指向 新增查詢,然後按一下 DMX

    查詢編輯器隨即開啟,並包含新的空白查詢。

  2. 將 INSERT INTO 語句的泛型範例複製到空白查詢中。

  3. 取代下列項目:

    [<mining structure name>]   
    

    取代為:

    Bike Buyer  
    
  4. 取代下列項目:

    <mining structure columns>  
    

    取代為:

    [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. 取代下列項目:

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

    取代為:

    OPENQUERY([Adventure Works DW],  
       'SELECT CustomerKey, Age, BikeBuyer,  
             CommuteDistance,EnglishEducation,  
             Gender,HouseOwnerFlag,MaritalStatus,  
             NumberCarsOwned,NumberChildrenAtHome,   
             EnglishOccupation,Region,TotalChildren,  
             YearlyIncome   
        FROM dbo.vTargetMail')  
    

    OPENQUERY 語句會參考 Adventure Works DW 多維度 2012 數據源,以存取檢視 vTargetMail。 檢視包含將用來定型採礦模型的源數據。

    完整語句現在應該如下所示:

    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,  
             NumberCarsOwned,NumberChildrenAtHome,   
             EnglishOccupation,Region,TotalChildren,  
             YearlyIncome   
        FROM dbo.vTargetMail')  
    
  6. 在 [檔案] 功能表上,按一下 [另存新檔 DMXQuery1.dmx]。

  7. 在 [ 另存新檔 ] 對話框中,瀏覽至適當的資料夾,並將檔案 Process Bike Buyer Structure.dmx命名為 。

  8. 在工具列上,按兩下 [ 執行] 按鈕。

在下一課,您將探索您在此課程中新增至採礦結構之採礦模型中的內容。

下一課

第4課:瀏覽自行車買家採礦模型