OpenBI Docs Buy

KMEANS.CENTERS OpenBI

The centres of the k-means clusters, with their sizes and scatter.

Group: Many variables at once. OpenBI’s own: DAX has no function of this name.

Syntax

KMEANS.CENTERS ( <table>, <k>, <name>, <expression> [, <name>, <expression>] … )
ParameterTypeDescription
tableTableThe rows to cluster.
kWhole numberHow many clusters: 1 to 100.
nameText
repeatable
A variable's name, a text in quotes; one or more variables.
expressionExpression
repeatable, evaluated for each row
That variable's number for each row.

Returns

Table. One row per cluster: its number (Cluster) and Size, then a column for each variable, named after it, with the cluster's average in that variable's own units, then Within SS, Between share and Silhouette.

Remarks

  • The clusters are those KMEANS gives for the same table, k and variables, numbered the same way.
  • Within SS is the cluster's scatter about its centre, in standardised units. Between share is the part of all the variation that the clustering explains (between SS over total SS, as R's kmeans prints it); it is the same on every row.
  • Silhouette is the mean silhouette of the cluster's rows.
  • Every variable is first put on one scale: how many standard deviations each row lies above or below that variable's mean. Liters and kroner then weigh alike, and a change of units changes nothing.
  • A row where any variable is blank is left out. A variable must be a number on every row (text is an error, even text that reads as a number), and one that is the same on every row is an error too.

Compared with DAX

An OpenBI function: DAX has none like it, so a measure or query that uses it works in OpenBI only, not in Power BI or Analysis Services.

Examples

The two kinds of shop, described

EVALUATE
VAR Shops =
    DATATABLE (
        "Shop", STRING, "Liters", INTEGER, "Visits", INTEGER,
        {
            { "A", 100, 10 }, { "B", 110, 12 }, { "C", 95, 9 },
            { "D", 400, 30 }, { "E", 420, 33 }, { "F", 390, 28 }
        }
    )
RETURN
    KMEANS.CENTERS ( Shops, 2, "Liters", [Liters], "Visits", [Visits] )
ClusterSizeLitersVisitsWithin SSBetween shareSilhouette
13101.66666666666710.33333333333330.04205216605376050.9838335282042210.925368511782275
23403.33333333333330.33333333333330.1196125519040270.9838335282042210.873847813396297

The centres of three delivery areas

EVALUATE
KMEANS.CENTERS ( Places, 3, "Lat", Places[Lat], "Lon", Places[Lon] )
ClusterSizeLatLonWithin SSBetween shareSilhouette
1759.914364714285710.77992885714296.634789896687150.6687192146937850.38928429657122
2659.938990833333310.7577772.51130423781470.6687192146937850.484500423495288
3359.9220710.70077866666670.7923294246845980.6687192146937850.53240850146802

KMEANS, KMEANS.ELBOW, AVERAGEX.

Last updated · OpenBI Studio 0.3.74