Using Mining Models

This section provides comprehensive guidance on understanding, creating, and leveraging mining models within SQL Server Analysis Services (SSAS). Data mining allows you to discover patterns, predict future trends, and gain actionable insights from your data.

What are Mining Models?

Mining models are the core components of data mining in Analysis Services. They are created using various algorithms to analyze data and reveal hidden relationships. Each model is designed to solve a specific business problem, such as:

Key Concepts

Data Sources and Data Mining Structures

Before creating a mining model, you need a data mining structure. This structure defines the data source views, input columns, predictable columns, and parameters that will be used by the mining model. The structure acts as a container for one or more mining models.

Mining Algorithms

Analysis Services supports a variety of data mining algorithms, each suited for different tasks:

Mining Model Properties

Each mining model has configurable properties that influence its behavior and output. These include algorithm-specific parameters and general model settings.

Workflow for Using Mining Models

The typical workflow for using mining models in Analysis Services involves the following steps:

  1. Define the Business Problem: Clearly understand what you want to achieve with data mining.
  2. Prepare Your Data: Ensure your data is clean, accurate, and suitable for analysis.
  3. Create a Data Mining Structure: Define the scope of data and analysis.
  4. Create Mining Models: Select appropriate algorithms and train models based on the structure.
  5. Explore and Evaluate Models: Use the mining model viewers and tools to understand model results and assess their accuracy.
  6. Generate Predictions: Use trained models to make predictions on new data.
  7. Integrate Insights: Apply the discovered knowledge and predictions to business decisions.
Note: Properly understanding your data and defining a clear business objective are crucial for successful data mining.

Tools for Working with Mining Models

Example: Creating a Classification Model

To create a classification model that predicts whether a customer will respond to a marketing campaign, you would typically:

  1. Connect to your Analysis Services instance in SSDT.
  2. Create a new Analysis Services project or open an existing one.
  3. Add a Data Source and Data Source View.
  4. Right-click on 'Mining Structures' and select 'New Mining Structure'.
  5. Choose the 'Classification' algorithm (e.g., Logistic Regression, Naive Bayes, Decision Trees).
  6. Link the structure to your Data Source View, defining input and predictable columns (e.g., customer demographics as input, response to campaign as predictable).
  7. Train the mining model.
  8. Use the Classification Viewer to explore the model's accuracy, decision trees, or probability charts.

-- Example DMX query to predict a value
SELECT
    [Model].[Customer_ID],
    [Model].[Predicted Response]
FROM
    [MyMiningModel]
PREDICTION JOIN
    OPENQUERY(MyDataSourceView, 'SELECT Customer_ID, Age, Income, Education FROM Customers')
ON
    [Model].[Customer_ID] = [Customers].[Customer_ID]
WHERE
    [Model].[__DISCRIMINATOR__] = 'Microsoft_LogisticRegression'
            
Tip: Experiment with different algorithms and parameters to find the model that best fits your data and business requirements.

This section aims to provide a foundational understanding of using mining models. For detailed steps and advanced techniques, refer to the sub-sections within the Mining Models documentation.