computeSilhouette: Compute Silhouette (k-means clustering).

Description Usage Arguments Value See Also Examples

View source: R/computeKmeans.R

Description

Compute Silhouette (k-means clustering).

Usage

1
2
computeSilhouette(channel, km, scaled = TRUE, silhouetteTableName = NULL,
  drop = TRUE, test = FALSE)

Arguments

channel

connection object as returned by odbcConnect.

km

an object of class "toakmeans" obtained with computeKmeans.

scaled

logical: indicates if computation performed on original (default) or scaled values.

silhouetteTableName

name of the Aster table to hold silhouette scores. The table persists silhoutte scores for all clustered elements. Set parameter drop=F to keep the table.

drop

logical: indicates if the table silhouetteTableName

test

logical: if TRUE show what would be done, only (similar to parameter test in RODBC functions: sqlQuery and sqlSave).

Value

computeSilhouette returns an object of class "toakmeans" (compatible with class "kmeans"). It adds a named list sil the km containing couple of elements: average value of silhouette value and silhouette profile (distribution of silhouette values on each cluster) profile

See Also

computeKmeans

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
if(interactive()){
# initialize connection to Lahman baseball database in Aster 
conn = odbcDriverConnect(connection="driver={Aster ODBC Driver};
                         server=<dbhost>;port=2406;database=<dbname>;uid=<user>;pwd=<pw>")
                         
km = computeKmeans(conn, "batting", centers=5, iterMax = 25,
                   aggregates = c("COUNT(*) cnt", "AVG(g) avg_g", "AVG(r) avg_r", "AVG(h) avg_h"),
                   id="playerid || '-' || stint || '-' || teamid || '-' || yearid", 
                   include=c('g','r','h'), scaledTableName='kmeans_test_scaled', 
                   centroidTableName='kmeans_test_centroids',
                   where="yearid > 2000")
km = computeSilhouette(conn, km)
km$sil
createSilhouetteProfile(km, title="Cluster Silhouette Histograms (Profiles)")
}

toaster documentation built on May 30, 2017, 3:51 a.m.