Java Reference
In-Depth Information
In these first lines, we have created the statement used to obtain
the number of customers in the specified cluster for each possible
value of the specified attribute. For example, if the selected attribute
is “PurchaseA,” which indicates how many times the customer
bought product A in the last month, contained in the table “Pur-
chases,” and the selected cluster is 1 from a clustering done with
5 clusters, we will get the following statement:
select count(*), PurchaseA
From Purchases a left outer join CLUSTER_TABLE_5 b
on a.CUSTID b.CUSTID
where (b.MyCluster_5 1)
group by a.PurchaseA;
In this statement, we have used “MyCluster” as the model name
prefix and “CLUSTER_TABLE” as the apply table name prefix.
Assume that we have customers that have bought product A 0, 1, 2,
or 3 times. We will have, as a result of the execution of the previous
statement, the number of customers that have bought this product 0,
1, 2, or 3 times belonging to cluster 1. The following lines show how
to retrieve the results from this statement.
20.
int lTotalSize 0;
21.
Map lCategories new HashMap();
22.
while (lResultSetCount.next()) {
23.
int lCategorySize lResultSetCount.getInt(1);
24.
String lCategory lResultSetCount.getString(2);
25.
lTotalSize lCategorySize;
26.
lCategories.put(lCategory, new Integer(lCategorySize));
27.
report("Category: " lCategory ": " lCategorySize);
28.
}
If we want to compare the profiles of the distribution of the
selected attribute, we must perform the same operation for the
customers that are not in this cluster, and get back the number of
customers for each possible value of this attribute, as shown below:
29.
lSQLCountQuery "select count(*), " iAttributeName " from "
30.
iInputDataSet " a left outer join "
31.
lClusterTableName " b on a."
32.
mIdentifierColumnName " b." mIdentifierColumnName
33.
" where (b." lClusterAttributeName " " iClusterIdx ")"
34.
" group by a." iAttributeName;
Search WWH ::




Custom Search