Mining Model Prediction
The Mining Model Prediction functions allow you to generate predictions from a data mining model that is stored in an Analysis Services cube. These functions can be used in T‑SQL queries, stored procedures, and client‑side applications to retrieve predictive results such as classifications, regressions, and clustering assignments.
Syntax
Transact‑SQL
SELECT
PREDICTION(
MODEL = <MiningModelName>,
PREDICTIVE_COL = <PredictiveColumnName>,
INPUT = ( <column_name_1=> value1,
<column_name_2=> value2,
... )
) AS PredictedValue
FROM <YourTableOrView>;
Example
This example demonstrates how to predict the CustomerSegment for a new customer using the CustomerSegmentationModel that was previously trained.
Transact‑SQL
SELECT
PREDICTION(
MODEL = N'CustomerSegmentationModel',
PREDICTIVE_COL = N'CustomerSegment',
INPUT = ( Age = 35,
Income = 72000,
Gender = N'M',
PurchasesLastYear = 12 )
) AS PredictedSegment;
Remarks
- The
PREDICTIONfunction can be used only with mining models that have been deployed to an Analysis Services instance. - All input columns must match the data type and naming used when the model was trained.
- When a column is omitted from the
INPUTlist, the model treats it as a missing value and applies the model's default handling (e.g., mean substitution). - For models that support probability outputs (e.g., classification), you can retrieve probabilities using the
PREDICTION_PROBABILITYfunction.
See also
| Related topics |
|---|
| Data Mining Models Overview |
| PREDICTION_PROBABILITY Function |
| Frequently Used Queries for Mining Models |
| Deploying Mining Models to Analysis Services |