Database Reference
In-Depth Information
Our next prediction query uses the Cluster DMX function to return the
cluster to which a new case, for which we know the business type, the total
number of permanent employees, the year established, the annual profit, and
the store surface, is most likely to belong. It also uses the ClusterProbability
DMX function to return the probability of belonging to that cluster. Note
that the query, again, is performed over the model not over the database (the
name in the FROM clause is the name of the model):
SELECT Cluster() AS [Cluster], ClusterProbability() AS [Probability]
FROM [NWDW Clustering] NATURAL PREDICTION JOIN
( SELECT ' Restaurant ' AS [Business Type],
2 AS [Permanent Employees], 1977 AS [Year Established],
2 AS [Annual Profit], 400 AS [Store Surface], 860 AS [Parking Surface] )
This yields the following result:
Cluster Probability
Cluster 7
0.7047
Finally, we can do the same as above, but for all the records in the
NewCustomers database, as we have done for the decision trees model, using
the PREDICTION JOIN and OPENQUERY DMX clauses, joining the model
and the database table:
SELECT T.CompanyName, T.BusinessType, T.ParkingSurface AS [PS],
T.PermanentEmployees AS [PE], T.StoreSurface AS [SS],
T.YearEstablished AS [YE], Cluster() AS [Cluster],
ClusterProbability() as [Probability]
FROM [NWDW Clustering] PREDICTION JOIN OPENQUERY(Sales,
' SELECT CompanyName, BusinessType, ParkingSurface,
PermanentEmployees, StoreSurface, YearEstablished
FROM NewCustomers ' )ASTON
[NWDW Clustering].[Business Type] = T.[BusinessType] AND
[NWDW Clustering].[Permanent Employees] =
T.[PermanentEmployees] AND
[NWDW Clustering].[Year Established] = T.[YearEstablished] AND
[NWDW Clustering].[Store Surface] = T.[StoreSurface] AND
[NWDW Clustering].[Parking Surface] = T.[ParkingSurface]
The result of this query is as follows:
CompanyName
BusinessType PS PE
SS
YE
Cluster Probability
La Grande Epicerie
Grocery
1135 2 1788 1963 Cluster 7
0.7979
L ' Amour Fou
Restaurant
918
4 1178 1955 Cluster 7
0.7806
Copenhagen Tavern
Tavern
0
3
667 1976 Cluster 8
0.5874
Au soleil
Cafe
542
3
374 1996 Cluster 8
0.5598
Mio Padre
Minimart
183
6
570 1965 Cluster 2
0.9943
...
...
... ... ...
...
...
...
 
Search WWH ::




Custom Search