SQL Server Analysis Services

Mining Model Operations

This document details various operations you can perform on mining models within SQL Server Analysis Services (SSAS). These operations are crucial for managing, querying, and refining your data mining solutions.

Important: Understanding these operations is key to building effective and efficient data mining models.

Creating and Deleting Mining Models

Mining models are created within a mining structure. Each model is based on a specific algorithm and targets a particular set of columns from the mining structure.

Training Mining Models

Training is the process of building the actual mining model from the data. This involves applying the chosen algorithm to the data defined in the mining structure.

Example: Training using AMO (C#)


using Microsoft.AnalysisServices.Tabular; // For Tabular, adjust for Multidimensional

// Assuming 'server' is an initialized Microsoft.AnalysisServices.Server object
// and 'cube' is a Microsoft.AnalysisServices.Cube or similar object

// For Multidimensional Models:
// var miningModel = cube.MiningModels.FindByName("MyDecisionTreeModel");
// if (miningModel != null)
// {
//     miningModel.Process(ProcessType.ProcessFull);
//     miningModel.Update();
// }

// For Tabular Models (using C# client libraries, conceptually similar):
// Assuming 'database' is an initialized Microsoft.AnalysisServices.Tabular.Database object
// and 'model' is a Microsoft.AnalysisServices.Tabular.Model object within it
// var tabularModel = database.Models.FindByName("MyTabularModel");
// if (tabularModel != null)
// {
//     tabularModel.Process(ProcessType.ProcessFull);
//     tabularModel.Update();
// }

// NOTE: The exact syntax depends on whether you are using Multidimensional or Tabular models
// and the specific AMO/TOM library version. This is a conceptual illustration.
            

Discovering and Querying Mining Models

Once a model is trained, you can query it to extract insights and predictions. Mining queries use the Data Mining Extensions (DMX) language.

Example: DMX Query for Predictions


SELECT
    Predict([MyClusterModel].[Cluster]) AS Cluster,
    [Customer].[CustomerID] AS CustomerID
FROM
    [MyClusterModel]
PREDICTION JOIN
    OPENROWSET(
        'Provider',
        'Microsoft.ACE.OLEDB.12.0',
        'SELECT * FROM [Excel 12.0;DATABASE=C:\Data\NewCustomers.xlsx]'
    ) AS T
ON T.[CustomerID] = [MyClusterModel].[CustomerID]
WHERE T.[CustomerID] IS NOT NULL
            

Validating and Scoring Models

Model validation helps assess the accuracy and reliability of your mining models.

Exporting and Importing Models

Models can be exported to share them or migrate them between servers. Importing brings these models into a new Analysis Services instance.

Algorithm-Specific Operations

Different algorithms have unique operations and properties:

For detailed information on specific algorithm operations, please refer to the algorithm's documentation.