Learn R Programming

toaster (version 0.5.5)

computeSilhouette: Compute Silhouette (k-means clustering).

Description

Compute Silhouette (k-means clustering).

Usage

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

Run this code
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)")
}

Run the code above in your browser using DataLab