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>] … )
| Parameter | Type | Description |
|---|---|---|
table | Table | The rows to cluster. |
mostK | Whole number | The largest number of clusters to try: 2 to 30. |
name | Text repeatable | A variable's name, a text in quotes; one or more variables. |
expression | Expression 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
KMEANSwould 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] )
| K | Within SS | Between share | Silhouette | Drop |
|---|---|---|---|---|
| 1 | 10 | 1.77635683940025e-16 | (blank) | (blank) |
| 2 | 0.161664717957787 | 0.983833528204221 | 0.899608162589286 | 0.983833528204221 |
| 3 | 0.0600745229339436 | 0.993992547706606 | 0.621953051352587 | 0.628400533568309 |
| 4 | 0.0225279461002288 | 0.997747205389977 | 0.355566399174687 | 0.625 |
How many delivery areas?
EVALUATE
KMEANS.ELBOW ( Places, 5, "Lat", Places[Lat], "Lon", Places[Lon] )
| K | Within SS | Between share | Silhouette | Drop |
|---|---|---|---|---|
| 1 | 30 | 2.368475785867e-16 | (blank) | (blank) |
| 2 | 17.5672952907469 | 0.414423490308435 | 0.361791713704491 | 0.414423490308435 |
| 3 | 9.93842355918644 | 0.668719214693785 | 0.451826132585895 | 0.434265583022264 |
| 4 | 4.88365766051469 | 0.837211411316177 | 0.494060366112296 | 0.508608419491183 |
| 5 | 3.14717356322207 | 0.895094214559264 | 0.461290349496276 | 0.355570397845948 |