SQL Server Analysis Services Documentation

Mining Model Prediction

This document explains how to use mining models to generate predictions in SQL Server Analysis Services.

Introduction to Prediction

After a data mining model has been created and trained, its primary purpose is to make predictions on new data. Analysis Services provides a rich set of prediction functions and tools to integrate predictions into your applications and reports. This section covers the core concepts and methods for obtaining predictions from trained models.

Prediction Queries

Prediction queries are executed against a trained mining model to generate predictions. These queries can be formulated using DMX (Data Mining Extensions) or the AMO (Analysis Management Objects) API. The basic structure of a prediction query involves specifying the model to query, the data to provide as input, and the type of prediction desired.

DMX Prediction Query Example

Here's a simple DMX query to predict whether a customer will churn, based on a hypothetical [Customer Churn Model]:

SELECT
    [Customer Churn Model].[IsCustomerChurned] AS predicted_churn,
    [Customer Churn Model].[IsCustomerChurned].PROBABILITY AS churn_probability
FROM
    [Customer Churn Model]
PREDICTION JOIN
    OPENQUERY(MyDataSourceView, 'SELECT CustomerID, Age, Income FROM Customers WHERE Status = ''Active''')
ON
    [Customer Churn Model].CustomerID = MyDataSourceView.CustomerID

Prediction Functions

DMX provides various functions to retrieve different types of predictions and associated information:

Prediction in Applications

Predictions generated by Analysis Services can be consumed in various ways:

Scenarios for Prediction

Best Practices

For more advanced prediction scenarios, refer to the specific documentation for each mining algorithm and DMX functions.