OpenBI Docs Buy

KMEANS.ELBOW OpenBI

The scatter about the centres for each number of clusters, to choose it.

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

Syntax

KMEANS.ELBOW ( <table>, <mostK>, <name>, <expression> [, <name>, <expression>] … )
ParameterTypeDescription
tableTableThe rows to cluster.
mostKWhole numberThe largest number of clusters to try: 2 to 30.
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. A row for each k from 1: K, Within SS, Between share, Silhouette (the mean over all rows) and Drop (the share of the remaining scatter that one more cluster takes away).

Remarks

  • Pick k where Drop falls away after a large value (the elbow), or where Silhouette is highest.
  • Each k is clustered just as KMEANS would cluster it.
  • With k = 1, Silhouette and Drop are blank, and Within SS is the whole scatter: (rows − 1) × the number of variables, as the variables are standardised.
  • With fewer rows than mostK, the rows stop at one cluster per row.
  • 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

Two is clearly enough

Two clusters take away 98 % of the scatter; a third adds little, and the silhouette falls.

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.ELBOW ( Shops, 4, "Liters", [Liters], "Visits", [Visits] )
KWithin SSBetween shareSilhouetteDrop
1101.77635683940025e-16(blank)(blank)
20.1616647179577870.9838335282042210.8996081625892860.983833528204221
30.06007452293394360.9939925477066060.6219530513525870.628400533568309
40.02252794610022880.9977472053899770.3555663991746870.625

How many delivery areas?

EVALUATE
KMEANS.ELBOW ( Places, 5, "Lat", Places[Lat], "Lon", Places[Lon] )
KWithin SSBetween shareSilhouetteDrop
1302.368475785867e-16(blank)(blank)
217.56729529074690.4144234903084350.3617917137044910.414423490308435
39.938423559186440.6687192146937850.4518261325858950.434265583022264
44.883657660514690.8372114113161770.4940603661122960.508608419491183
53.147173563222070.8950942145592640.4612903494962760.355570397845948

KMEANS, KMEANS.CENTERS, PCA.COMPONENTS.

Last updated · OpenBI Studio 0.3.74