UMAP OpenBI
A map of the rows in two dimensions, near rows near each other (UMAP).
Group: Many variables at once. OpenBI’s own: DAX has no function of this name.
Syntax
UMAP ( <table>, <key> [, <settings>], <name>, <expression> [, <name>, <expression>] … )
| Parameter | Type | Description |
|---|---|---|
table | Table | The rows to map. |
key | Expression evaluated for each row | What names each row in the result. |
settings | Text optional | Settings as name=value, commas between. dims, the map's dimensions: 2 by default. neighbors, 15 by default; min_dist, 0.1; spread, 1. epochs, the rounds of layout: when 0, the default, 500 up to 10,000 rows and 200 above. seed, for another random start. |
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 row of the table that has every variable: Key, then D1, D2 (and more with dims) with the row's place on the map.
Remarks
- UMAP (uniform manifold approximation and projection) lays the rows out so that rows alike in their variables lie near each other. Distances between groups far apart mean little, and the axes have no units.
- neighbors is how many nearest rows each row looks to: few for fine detail, more for the overall shape. min_dist is how closely rows may pack together.
- The same rows and settings always give the same map; another seed gives a different map with the same neighbourhoods.
- The settings are read as such only when they come right after the key and hold an =; an unknown setting is an error.
- 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.
- The map needs more rows than dimensions plus one.
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 groups of shops, apart
With three neighbours each, the small shops and the big shops form two tight groups, well apart.
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
UMAP ( Shops, [Shop], "neighbors=3", "Liters", [Liters], "Visits", [Visits] )
| Key | D1 | D2 |
|---|---|---|
| A | -12.7634585021131 | 12.6956140530186 |
| B | -12.45749354388 | 13.2634797027964 |
| C | -13.1675080716375 | 13.1886895652525 |
| D | -5.66287316530928 | 11.5737150137555 |
| E | -5.00725696098202 | 11.3312930763718 |
| F | -5.58573088441977 | 10.7896180072213 |
Places by location and crates
EVALUATE
UMAP (
Places,
Places[District],
"Lat", Places[Lat],
"Lon", Places[Lon],
"Crates", Places[Crates]
)
| Key | D1 | D2 |
|---|---|---|
| Alnabru | 2.33917955229539 | 0.292877470911355 |
| Grünerløkka | 2.27104902905585 | 2.68078884946325 |
| Majorstuen | 1.72496647471486 | 2.18943938062332 |
| Frogner | 2.25620947444369 | 1.73121664379741 |
| Bjørvika | 3.0630876338308 | 2.13170265385851 |
| Nydalen | 0.333577027033987 | 1.83152422124987 |
| Storo | 0.864262244204334 | 1.15849708111757 |
| Tøyen | 2.88716396604639 | 1.18536314462576 |
| Sagene | 0.704288267843799 | 2.54348860393536 |
| St. Hanshaugen | 1.48694376090649 | 2.86360299863653 |
| Grønland | 3.40867739388779 | 1.57802498907059 |
| Skøyen | 1.66058340557907 | 1.29356134382422 |
| Ullevål | 0.360390437941256 | 1.33806883297923 |
| Torshov | 1.08734074963126 | 2.08533908019682 |
| Kampen | 2.93451515665579 | 0.485688838898826 |
| Vålerenga | 3.57096582196581 | 0.77391645314724 |