Microsoft Docs – Analysis Services

Mining Model Objects

The Mining Model Objects are the core components of a data mining solution in Microsoft SQL Server Analysis Services. They represent the structures, definitions, and runtime behavior of a mining model.

Overview

Mining model objects include:

  • MiningModel – logical definition of a model.
  • MiningStructure – a set of columns (attributes) used in model training.
  • MiningColumn – individual attribute definition, including type and transformation.
  • MiningModelParameters – algorithm-specific settings.
  • MiningModelContent – the persisted model data (model bin).
MiningStructure Properties
PropertyData TypeDescription
NameStringUnique name of the structure.
KeyColumnsCollectionColumns that uniquely identify a row.
AttributeColumnsCollectionColumns used as inputs for mining.
PredictionColumnsCollectionColumns that can be predicted.
MiningModel Methods
-- Create a mining model
CREATE MINING MODEL dbo.CustomerSegmentationModel
USING Microsoft_Clustering
AS
SELECT *
FROM dbo.CustomerData;
                

The most common methods include:

  • Train – builds the model from data.
  • Predict – returns predicted values for new data.
  • Refresh – incrementally updates the model.
Example: Creating a Decision Tree Model
-- Step 1: Define the mining structure
CREATE MINING STRUCTURE dbo.ChurnStructure
(
    CustomerID LONG,
    Age LONG,
    Tenure LONG,
    Balance DOUBLE,
    NumOfProducts LONG,
    HasCrCard LONG,
    IsActiveMember LONG,
    EstimatedSalary DOUBLE,
    Exited LONG -- prediction column
)
USING Microsoft_Decision_Trees;

-- Step 2: Create the mining model
CREATE MINING MODEL dbo.ChurnModel
FROM dbo.ChurnStructure
AS
SELECT *
FROM dbo.ChurnData;

-- Step 3: Query predictions
SELECT
    CustomerID,
    Predict(Exited) AS PredictedChurn
FROM
    OPENQUERY([SSAS_Server],
    'SELECT *
     FROM dbo.ChurnModel
     WHERE Age > 30 AND Balance > 50000');