Mining Object Model
The Mining Object Model (MOM) provides a structured way to interact with and manage data mining objects within SQL Server Analysis Services. This object model allows developers and administrators to programmatically create, modify, and query mining structures, models, and related objects.
Understanding the Core Components
The MOM is built around several key object types:
- Mining Structure: Represents the schema of the data used for mining, including tables, columns, and their relationships. It acts as a container for one or more mining models.
- Mining Model: A learned model based on a specific algorithm applied to a mining structure. Each model contains learned patterns and predictive logic.
- Content: Refers to the learned patterns and logic of a specific mining model. This can be represented in various ways depending on the algorithm (e.g., decision trees, association rules, clusters).
- Column: Represents a data attribute within a mining structure. Columns can have different usage properties (e.g., predictable, input, key).
- Table: Represents a data source table or view used in the mining structure.
Key Operations Supported by MOM
The Mining Object Model facilitates a wide range of operations:
- Creation: Programmatically create new mining structures and models.
- Configuration: Define column usage, specify algorithms, and set model parameters.
- Training: Initiate and monitor the training process for mining models.
- Exploration: Query the content of trained mining models to understand patterns and insights.
- Prediction: Use trained models to make predictions on new data.
- Management: Delete, backup, restore, and manage the lifecycle of mining objects.
Using MOM with AMO
The Mining Object Model is part of the Analysis Management Objects (AMO) library. AMO provides a .NET Framework-compliant object model that exposes the administrative and object model features of Analysis Services. You can leverage AMO in your applications to:
- Automate the creation and deployment of data mining solutions.
- Integrate data mining capabilities into business intelligence applications.
- Perform administrative tasks on data mining objects.
Example: Creating a Basic Mining Structure
Here's a conceptual example of how you might use AMO to create a mining structure:
// Using Microsoft.AnalysisServices.dll
using Microsoft.AnalysisServices.Tabular; // Note: This example is conceptual and might lean towards Tabular, but MOM concepts apply to Multidimensional too.
// Assuming 'server' is an initialized Microsoft.AnalysisServices.Server object
// and 'database' is an initialized Database object.
// Define the mining structure
MiningStructure ms = new MiningStructure();
ms.ID = "MyCustomerMiningStructure";
ms.Name = "Customer Data Mining Structure";
// Define a source table
Table sourceTable = new Table();
sourceTable.ID = "DimCustomer";
sourceTable.Name = "Customer Dimension";
sourceTable.SourceType = SourceType.DataSourceView;
sourceTable.Source = "MyDataSourceView"; // Assuming a DataSourceView named 'MyDataSourceView'
// Define columns
Column customerKeyColumn = new Column();
customerKeyColumn.ID = "CustomerKey";
customerKeyColumn.Name = "Customer Key";
customerKeyColumn.DataType = DataType.Int64;
customerKeyColumn.KeyColumn = true; // Marks this as a key column
sourceTable.Columns.Add(customerKeyColumn);
Column ageColumn = new Column();
ageColumn.ID = "Age";
ageColumn.Name = "Age";
ageColumn.DataType = DataType.Int64;
ageColumn.SourceColumn = "Age"; // Maps to the source column name
ageColumn.ModelingFlags.Add(new ModelingFlag { Flag = ModelingFlagName.IsInput }); // Mark as input
sourceTable.Columns.Add(ageColumn);
// Add the table to the mining structure
ms.SourceTables.Add(sourceTable);
// Add the mining structure to the database
database.MiningStructures.Add(ms);
// Update the database to commit changes
database.Update();
Further Resources
- Microsoft Analysis Management Objects (AMO) Reference
- Data Mining Algorithms in Analysis Services
- Tutorial: Building a Basic Cube
Important: Ensure you have the correct AMO libraries referenced in your project and that your Analysis Services instance is accessible.