This topic has not yet been rated - Rate this topic

# PredictCaseLikelihood (DMX)

SQL Server 2012

This function returns the likelihood that an input case will fit in the existing model. Used only with clustering models.

```
PredictCaseLikelihood([NORMALIZED|NONNORMALIZED])
```
NORMALIZED

Return value contains the probability of the case within the model divided by the probability of the case without the model.

NONNORMALIZED

Return value contains the raw probability of the case, which is the product of the probabilities of the case attributes.

Models that are built by using the Microsoft Clustering and Microsoft Sequence Clustering algorithms.

Double-precision floating point number between 0 and 1. A number closer to 1 indicates that the case has a higher probability of occurring in this model. A number closer to 0 indicates that the case is less likely to occur in this model.

By default, the result of the PredictCaseLikelihood function is normalized. Normalized values are typically more useful as the number of attributes in a case increase and the differences between the raw probabilities of any two cases become much smaller.

The following equation is used to calculate the normalized values, given x and y:

• x = likelihood of the case based on the clustering model

• y = Marginal case likelihood, calculated as the log likelihood of the case based on counting the training cases

• Z = Exp( log(x) – Log(Y))

Normalized = (z/ (1+z))

The following example returns the likelihood that the specified case will occur within the clustering model, which is based on the Adventure Works DW database.

```SELECT
PredictCaseLikelihood() AS Default_Likelihood,
PredictCaseLikelihood(NORMALIZED) AS Normalized_Likelihood,
PredictCaseLikelihood(NONNORMALIZED) AS Raw_Likelihood,
FROM
[TM Clustering]
NATURAL PREDICTION JOIN
(SELECT 28 AS [Age],
'2-5 Miles' AS [Commute Distance],
0 AS [Number Cars Owned],
0 AS [Number Children At Home]) AS t
```

Expected results:

Default_Likelihood

Normalized_Likelihood

Raw_Likelihood

6.30672792729321E-08

6.30672792729321E-08

9.5824454056846E-48

The difference between these results demonstrates the effect of normalization. The raw value for CaseLikelihood suggests that the probability of the case is about 20 percent; however, when you normalize the results, it becomes apparent that the likelihood of the case is very low.