MSDN Documentation

Microsoft Developer Network

Sequence Clustering in SQL Server Analysis Services

Sequence clustering is a data mining technique used to discover patterns in sequential data. In SQL Server Analysis Services (SSAS), sequence clustering algorithms can group similar sequences together, helping you understand customer behavior, website navigation patterns, or any other data that involves ordered events.

Understanding Sequence Clustering

Sequential data consists of events that occur in a specific order over time. For example:

Sequence clustering aims to identify common subsequences or patterns of behavior within this data. By grouping similar sequences, you can gain insights into:

The Sequence Clustering Algorithm in SSAS

SQL Server Analysis Services provides an implementation of the sequence clustering algorithm that leverages techniques like Markov chains and probabilistic models to group sequences. The algorithm identifies clusters based on the similarity of event sequences within those clusters.

Key Concepts:

Implementing Sequence Clustering in SSAS

To implement sequence clustering in SSAS, you typically follow these steps:

  1. Data Preparation: Ensure your data is structured to represent sequences. This usually involves a table with columns for a case identifier (e.g., customer ID), an order identifier (e.g., timestamp or sequence ID), and the event itself.
  2. Create a Data Mining Structure: In SQL Server Data Tools (SSDT) or Visual Studio with the Analysis Services projects extension, create a new Analysis Services project. Define a data source view that includes your sequential data.
  3. Create a Mining Model: Within the data mining project, create a new mining model. Select the "Sequence Clustering" algorithm.
  4. Configure Model Settings:
    • Specify the case table and the sequence identifier column.
    • Identify the predictable column (the event).
    • Choose whether to use the Sequence Clustering algorithm or the MS Sequence Clustering algorithm (a variation).
    • Set parameters such as the maximum number of clusters or the minimum number of sequences per cluster.
  5. Train the Model: Process the mining model using your prepared data. SSAS will analyze the data and build the clusters.
  6. Explore and Visualize: Use the mining viewer in SSDT to explore the generated clusters. You can see the common subsequences associated with each cluster and the characteristics of the sequences within them.

Example XMLA for Model Creation:


<Create MiningModel xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
    <Name>SequenceClusteringModel</Name>
    <DatabaseID>YourDatabaseName</DatabaseID>
    <MiningStructureID>YourMiningStructureName</MiningStructureID>
    <Algorithm>
        <Name>CLUSTERING</Name>
        <Parameters>
            <Parameter>
                <Name>CLUSTER COUNT</Name>
                <Value>5</Value>
            </Parameter>
            <Parameter>
                <Name>NORMALIZATION</Name>
                <Value>PROBABILITY</Value>
            </Parameter>
        </Parameters>
    </Algorithm>
    <Source>
        <MiningModelSource>
            <ColumnBindings>
                <ColumnBinding>
                    <AttributeID>CaseIDColumn</AttributeID>
                    <MiningField>
                        <Name>CaseID</Name>
                        <ModelingFlags>
                            <Caseldentifier/>
                        </ModelingFlags>
                    </MiningField>
                </ColumnBinding>
                <ColumnBinding>
                    <AttributeID>SequenceIDColumn</AttributeID>
                    <MiningField>
                        <Name>SequenceID</Name>
                        <ModelingFlags>
                            <SequenceIdentifier/>
                        </ModelingFlags>
                    </MiningField>
                </ColumnBinding>
                <ColumnBinding>
                    <AttributeID>EventColumn</AttributeID>
                    <MiningField>
                        <Name>Event</Name>
                        <ModelingFlags>
                            <Predict/>
                        </ModelingFields>
                    </MiningField>
                </ColumnBinding>
            </ColumnBindings>
        </MiningModelSource>
    </Source>
</Create MiningModel>
            
Note: Ensure your data is clean and appropriately formatted before creating the mining structure. The quality of your input data significantly impacts the effectiveness of the clustering.

Using the Sequence Clustering Model

Once the model is trained, you can use it for various purposes:

Tip: Experiment with different parameter settings, such as the number of clusters, to find the most meaningful patterns in your data.

Related Topics