← 10. Patterns & segmentation
Self-organizing map
Try this analysis →

Self-Organizing Maps (SOM)

It learns to place similar observations close together on a map.

BMU and neighborhood functionU-MatrixComponent planesQE & TE

BMU6 × 6 grid · 36 nodesType A · Stable conditions480 · 50%Type B · Check ventilation300 · 31.25%Type C · Check cooling & power180 · 18.75%

Suppose you manage the indoor environment of a smart building. The building manager collects temperature, humidity, carbon dioxide concentration, noise level and power use for each space with sensors. But as the number of measurements grows, it becomes hard to see at a glance which spaces have similar conditions, or where ventilation and cooling problems are concentrated.

One method for this situation is the self-organizing map (SOM). A SOM is an unsupervised learning method that maps observations described by many variables onto a grid, usually two-dimensional. Because it learns to place similar observations near each other on the map, it helps you explore complex data and understand the characteristics of each type.

A SOM is a bit different from methods that just assign cluster numbers. Each grid node has a representative vector with the same dimension as the original data, and during training not only the most similar node but also its neighbors are adjusted. In the process, similar patterns in the data can end up arranged continuously across the map.

In this article we'll cover the basic structure of a SOM and how it learns, a worked example with sensor data, map size and training settings, the U-Matrix and component planes, clustering the map, evaluating performance and reporting results.

SECTION 1

What is a self-organizing map?

A self-organizing map is a neural network–based unsupervised learning method that represents similar patterns in high-dimensional data on a low-dimensional grid.

It usually uses a two-dimensional grid with nodes arranged in fixed rows and columns.

6 × 6 grid · 36 nodesPrototype of one nodeMean temp.-0.06Mean humidity-0.56Mean CO₂-0.71Mean noise+0.27Daily power-0.27Standardized value (0 = mean)
Grid and node prototypes

Each node has a weight vector (prototype) as long as the number of input variables. For example, with five variables (temperature, humidity, CO₂ concentration, noise and power use), each node is also represented by a vector of five values.

After training, each observation is mapped to the node whose prototype is closest to it. This shows which areas have similar conditions and where on the map particular environmental patterns gather. However, distance on the SOM grid is not exactly the same as actual distance in the original data space.

SECTION 2

How is a SOM different from K-means?

K-means splits the data into a preset number of clusters and finds the center of each cluster.

A SOM is similar in that it learns representative vectors, but it differs in that those vectors sit on a connected grid, so it also learns the relationships between neighboring nodes.

AspectK-MeansSOM
Main outputCluster labels and centroidsGrid map and a prototype for each node
Relationships between centersNo spatial structureGrid neighborhood relationships built into training
Number of clustersUsually set in advanceNumber of map nodes is separate from final number of clusters
Main useClear cluster assignmentsPattern exploration, visualization, follow-up clustering

So the number of SOM nodes is not the final number of clusters. For example, a 6×6 grid has 36 nodes, but you can analyze the similarity of the nodes again and end up defining three operating types.

SECTION 3

Worked example: indoor environment patterns in a smart building

Suppose a facilities team analyzed 960 space-day observations collected from common areas and meeting rooms on 8 floors of a smart building.

Each observation summarizes one day of sensor readings.

VariableUnitMeaning
Mean temp.°CDaily mean temperature
Mean humidity%Daily mean humidity
Mean CO₂ppmIndicator of ventilation status
Mean noisedB(A)Indoor noise level
Daily power usekWhPower used by the space

The research question is: "Considering the five environmental indicators together, what operating patterns do the space-day records fall into?"

The goal of this example is not to pin down the cause of a particular equipment failure, but to group similar environmental states and find areas that need further inspection.

SECTION 4

How do you prepare data before running a SOM?

A SOM learns based on distances between observations and prototypes.

So when variables differ in units and magnitude, variables with large numbers can dominate the distance. For example, CO₂ is measured in hundreds of ppm and humidity in tens of percent, so using the raw data as is can distort the comparison. To reduce this, you can standardize each variable (z-scores).

zij = ( xij − x̄j ) ÷ sj

You should also check for extreme values caused by sensor errors, missing observations and mismatched measurement periods. But simply removing extreme values that matter operationally, such as genuinely high CO₂, can erase the very patterns you need to find. It's best to train the SOM after unifying units, handling missing data, checking outliers and standardizing.

SECTION 5

How does a SOM learn?

The heart of SOM training is finding the best matching unit (BMU) and adjusting that node together with the nodes around it.

First, the distance between the input observation and every prototype on the grid is calculated, and the closest node is selected.

BMUInput observation xOne day's record5 variablesClosest nodeBMU1 cell away2 cells away
BMU and neighborhood update

wj(t+1) = wj(t) + η(t) · hb,j(t) · [ x − wj(t) ]

η(t) is the learning rate, and hb,j(t) is the neighborhood weight based on grid distance from the BMU. A common approach is to move a wide area together early in training and then shrink the range of adjustment later to refine the detailed structure.

SECTION 6

How do you set the map size and training settings?

In this example, assume a 6×6 grid with 36 nodes in total.

Each of the 960 observations is assigned to the closest of the 36 nodes. Not every node gets the same number of observations, and some nodes may be left empty.

SettingExample valueWhat to check
Map size6×6Balance between detailed patterns and interpretability
DistanceEuclidean distanceWhether it suits standardized continuous data
Initial learning rate0.50Decay schedule and convergence
Initial neighborhood radius3 grid stepsShrinks as training progresses
Iterations10,000Check result stability and convergence
Random seed42Ensures reproducible results

These numbers are examples for explanation, not universally optimal values. In practice, you should train several times with different map sizes and starting values and compare stability and how interpretable the maps are.

SECTION 7

How do you read a trained SOM?

After training, each observation is assigned to its BMU.

Observations gathered in the same node on the map show measurement patterns similar to its prototype, and neighboring nodes are trained to have similar patterns too.

3239352741384725183627279243617317271312529323536232273537247253639Hit countFewManyMax 47Min 1
Hit count map

A heat map or hit count shows the number of observations assigned to each node. If many observations pile up in one node, it may be a frequently occurring environmental state. But a high count doesn't by itself mean that state is desirable or safe.

Also, even if values change smoothly between neighboring nodes, not every local neighborhood relationship is fully preserved. In building a low-dimensional map, a SOM can lose some of the distance information in the original data.

SECTION 8

What does the U-Matrix show?

The U-Matrix (unified distance matrix) is a map that visualizes the distances between the prototypes of neighboring nodes.

If neighboring nodes have similar prototypes, the value is small; if they differ, it is large.

Distance to neighboring nodesCloseFar
U-Matrix

Areas with a run of low distance values can be seen as zones where similar environmental patterns gather. Conversely, bands of high distance values may be boundaries between different patterns.

For example, if a high-distance zone appears between two separate areas of the U-Matrix, the observations assigned to those two areas may have different environmental characteristics. But a U-Matrix boundary should not be read as an automatically confirmed cluster boundary. Its shape can also change with the map size, the distance measure and the standardization method.

SECTION 9

How do you interpret component planes?

A component plane shows each node's prototype value for one input variable on the map.

Mean temp.Mean humidityMean CO₂Mean noiseDaily powerLowHigh
Component planes

For example, areas with high values on the CO₂ component plane may also show high values on the power-use component plane. When two maps show similar patterns like this, it's a clue that those variables vary in similar ways across the trained map.

But visually similar patterns are not enough to conclude a causal relationship between the two variables. In this example, you can compare the component planes for temperature, humidity, CO₂, noise and power use one by one to see in which areas a high-CO₂ pattern, a high-temperature/high-power pattern and a relatively stable environmental pattern appear.

SECTION 10

Can you build actual clusters from SOM results?

Yes. But you don't have to use the SOM's 36 nodes as 36 clusters.

You can apply hierarchical clustering or K-means to the trained node prototypes to group them into larger types. For example, suppose the 36 nodes were grouped into three types and each observation was assigned to the type that its BMU belongs to.

Type A · Stable conditions480 · 50%Low CO₂ and noise, stable temperatureType B · Check ventilation300 · 31.25%Relatively high CO₂ and humidityType C · Check cooling & power180 · 18.75%High temperature and power use
Three operating types
Operating typeObservationsShareKey features
Type A: Stable conditions48050%Relatively low CO₂ and noise, stable temperature
Type B: Check ventilation30031.25%Relatively high CO₂ and humidity
Type C: Check cooling & power18018.75%Relatively high temperature and power use
Total960100%

The names of the operating types are not labels whose meaning the statistical model guarantees automatically. They should be assigned after reviewing each type's actual variable values and the facility's operating standards. In particular, types B and C are only a reference for prioritizing further inspection, not a confirmed diagnosis of failures in the ventilation or cooling equipment.

SECTION 11

How do you evaluate a trained SOM?

A SOM can't be called a good analysis just because the map image looks nice.

You need to check both how well it represents the raw data and how well it preserves the relationships between nearby observations. The standard measures are quantization error (QE) and topographic error (TE).

Quantization error QEPrototypeMean distance to BMUTopographic error TE1st2ndError if 1st and 2nd aren't neighborsQE0.74TE0.06Empty node2 / 36
Quantization error and topographic error

Quantization error is the mean distance between each observation and its BMU's prototype; the lower it is, the more closely the map nodes represent the data. Topographic error is commonly measured as the proportion of observations whose closest and second-closest nodes are not neighbors on the grid. A lower value can be evidence that local topological relationships were better preserved.

DiagnosticExample resultInterpretation
Quantization error (QE)0.74Mean distance to the BMU in standardized space
Topographic error (TE)0.06For about 6% of observations, the top two BMUs are not adjacent
Empty node2 / 36Number of nodes with no observations assigned

QE depends on the map size and variable scaling, and TE depends on the grid structure, so keep the same preprocessing and evaluation rules when comparing different settings. If you grouped the node prototypes into final clusters, you can also check silhouette coefficients and cluster stability as supporting evidence.

SECTION 12

What should you watch out for when using a SOM?

Put the variables on the same scale.

If sensor variables in different units go straight into the distance calculation, the results can be skewed toward some variables. Record the standardization method and apply the same rule in repeated analyses.

Don't assume that looking close on the map means being close in reality.

A SOM represents similarity on a low-dimensional grid, but it does not preserve every distance relationship in the original data space.

Results can be sensitive to map size and starting values.

Even with the same data, results can change with the number of nodes, the learning rate and the random initialization, so it's good to train repeatedly under several settings to check stability.

Don't carelessly assume that the observations are independent.

This example uses data from the same spaces measured on many days, so repetition over time and space-specific characteristics are both present. A SOM provides exploratory mapping, but it does not perform causal inference on repeated observations.

Don't interpret cluster names as actual causes.

Even if you find a high-CO₂ type, there may be many reasons, such as sensor errors or a temporary increase in occupancy. Check on-site information and further diagnostics before making operational decisions.

SECTION 13

How do you report SOM results?

When reporting SOM results, it's good to present the unit of analysis and sample size, input variables, handling of missing data and outliers, standardization, map size, learning rate and radius settings, random seed, evaluation measures and the characteristics of the final types together.

Sample write-up

To explore indoor environment patterns in a smart building, a self-organizing map (SOM) was applied to 960 space-day sensor observations collected on 8 floors. The input variables were mean indoor temperature, relative humidity, CO₂ concentration, noise level and daily power use, and each variable was standardized. Training on a 6×6 grid gave a quantization error of 0.74 and a topographic error of 0.06.

The prototypes of the 36 trained nodes were further clustered to derive three operating types. Type A contained 480 observations (50%), type B 300 (31.25%) and type C 180 (18.75%). Type B was characterized by relatively high CO₂ and humidity, and type C by high temperature and power use. These results can be used to summarize the smart building's environmental states by type and to select targets for further inspection, but no type directly indicates a failure of particular equipment.

In actual research, presenting the SOM map together with the U-Matrix and the key component planes makes it easier to understand how each operating type is separated on the map. It's also good to report the stability across repeated training runs and the final clustering method.

✓Wrap-up

A SOM explores similar patterns on a map

A self-organizing map is an unsupervised learning method that places observations made up of many variables on a grid to explore similar patterns.


Each node has a prototype with the same dimension as the input variables, and during training the best matching unit and its neighboring nodes are adjusted together.

In the results, you can use the hit count, U-Matrix and component planes to see how observations are distributed, where the boundaries between nodes lie and the pattern of each variable. If needed, you can cluster the node prototypes again to organize them into types that are easier to interpret.

But the visual structure of the map does not accurately preserve every relationship in the actual data. Review variable standardization, map size, initialization and training settings, quantization and topographic error, and the stability of the results together.

KEY TAKEAWAY

The core of a SOM is not just dividing data into a few clusters, but looking on a map at how similar observations relate to one another and how patterns shift from one to the next.