# Self-organizing Maps

A Machine Learning concept (Learned models) in the LuxAlgo Library.

## What are Self-organizing Maps?

A self-organizing map (SOM), introduced by Teuvo Kohonen, is an unsupervised [neural network](https://www.luxalgo.com/library/concept/neural-networks/) that projects high-dimensional data onto a low-dimensional grid of nodes, usually two-dimensional, while preserving topology: similar inputs land on nearby nodes. Training presents feature vectors one at a time; the best-matching node and its grid neighbors are pulled toward each input, with the neighborhood radius and learning rate shrinking as training proceeds. Each node ends up holding a prototype, a representative combination of feature values.

For markets, the grid becomes a map of conditions: feed in volatility, momentum, and volume features and regions of the map come to correspond to regimes, with the live bar's best-matching node saying where conditions currently sit. The approach is closely related to [K-means](https://www.luxalgo.com/library/concept/k-means-regime-clustering/) regime grouping, since both learn prototypes. Its supervised sibling, learning vector quantization (LVQ), attaches class labels to the prototypes so the nearest one's label becomes a directional signal, which is how some charting implementations of this family work.

The method is Finnish in origin: Kohonen introduced it in the early 1980s while at the Helsinki University of Technology, and it became one of the most cited neural architectures of the pre-deep-learning era, applied to speech, image, and document organization. Its enduring appeal is interpretability. Where most networks are opaque, a trained SOM can literally be drawn: each node's prototype can be inspected directly, and shading the distances between neighboring prototypes (the U-matrix) reveals the natural groupings in the data.

Getting useful maps from market data is mostly [feature engineering](https://www.luxalgo.com/library/concept/feature-engineering/) and preprocessing. Inputs must be scaled to comparable ranges or the distance calculation is dominated by whichever feature has the largest units, and many workflows compress correlated inputs with [PCA](https://www.luxalgo.com/library/concept/pca/) first. Grid size, learning rate, and neighborhood decay are free parameters with no market-given answer, and because prices are non-stationary, a map trained on one era can misfile the next, which motivates periodic retraining or [online updating](https://www.luxalgo.com/library/concept/online-incremental-learning/). The map itself is descriptive: turning a region into a trade still requires attaching outcomes, through LVQ labels or a separate [label definition](https://www.luxalgo.com/library/concept/label-definition-and-prediction-horizon/) step.

## How to put a self-organizing map to work on a chart

A SOM is a model rather than a chart pattern, so identification means building and reading one; charting implementations follow roughly the same sequence.

1. Choose a handful of features per bar, such as returns over several horizons, a volatility measure, and relative volume, and normalize each to a comparable scale.
2. Pick a modest grid and train on a rolling historical window; small maps are typical for single-symbol work because each node needs many example bars.
3. Inspect the trained map and label regions by the average behavior of the bars that land there: quiet drift, strong trend, high-volatility reversal.
4. Plot the live bar's best-matching node or region on the chart, coloring bars or a status pane by regime.
5. Watch trajectories as well as states: drift across adjacent nodes suggests gradual regime change, while a jump to a distant region flags an abrupt shift.
6. Retrain on a schedule and compare successive maps; regions that reshuffle on every retrain are unstable and should not carry trading logic.

## How traders use it

- Regime mapping: train the map on historical feature vectors, label coherent regions (quiet trend, volatile range), and key strategy logic off which region the current bar maps into.
- Analog finding: the best-matching node identifies which historical conditions most resemble the present, a prototype-based cousin of [kNN analog forecasting](https://www.luxalgo.com/library/concept/knn-analog-forecasting/).
- LVQ classification: prototypes carry bullish or bearish outcome labels and are nudged toward inputs of their own class during training; live classification is simply the nearest prototype's label.
- Anomaly detection: when the live bar sits unusually far from even its best-matching prototype, current conditions resemble nothing in the training window, which argues for reducing model-driven risk.
- As one voice in [ensemble voting](https://www.luxalgo.com/library/concept/ensemble-voting-of-signals/): the SOM's regime label gates or weights other signals, for example only honoring mean-reversion entries when the map sits in a range-like region.

## Self-organizing maps vs related methods

- **K-means** (https://www.luxalgo.com/library/concept/k-means-regime-clustering/): Both learn prototypes from unlabeled data. K-means prototypes are unordered, while a SOM constrains grid neighbors to stay similar, adding a geography of regimes at some cost in raw fit.
- **kNN Analog Forecasting** (https://www.luxalgo.com/library/concept/knn-analog-forecasting/): kNN keeps every historical observation and searches raw history at prediction time; a SOM compresses history into prototypes first, trading fine detail for speed and a stable, inspectable map.
- **Gaussian Mixture Models** (https://www.luxalgo.com/library/concept/gaussian-mixture-models/): GMMs describe data with overlapping probability components and return soft membership probabilities; a SOM returns a hard best-matching node arranged spatially. One quantifies uncertainty, the other visualizes structure.
- **Hidden Markov / Markov-switching Regimes** (https://www.luxalgo.com/library/concept/hidden-markov-markov-switching-regimes/): HMMs model regime persistence and transition probabilities through time; a SOM has no time model and classifies each bar independently, which is why the two are sometimes combined.

## FAQ

### How does a self-organizing map differ from K-means?

Both learn a set of prototypes, but a SOM arranges them on a grid where neighboring prototypes are constrained to stay similar, while K-means prototypes have no spatial relationship to each other. That topology lets a SOM show how regimes relate, whether the market drifted to an adjacent state or jumped across the map, which a plain group label cannot express.

### What is LVQ and how does it relate to SOMs?

Learning vector quantization is the supervised member of the same Kohonen family. Prototypes are assigned class labels and, during training, move toward inputs of their own class and away from others; prediction returns the nearest prototype's label. Trading implementations often prefer LVQ because it yields a directional output directly, whereas a raw SOM only says which region of the map is active.

### Who invented the self-organizing map?

Teuvo Kohonen, a Finnish researcher at the Helsinki University of Technology, published the method in the early 1980s; the maps are still often called Kohonen maps. He also developed learning vector quantization, the supervised variant that trading implementations frequently use.

### Can a self-organizing map predict price direction?

Not by itself. A SOM is unsupervised: it describes where current conditions sit relative to history but attaches no outcome. Direction requires a supervised step, either LVQ labels on the prototypes or a downstream model trained on each region's forward returns, and any probability that step produces deserves the same scrutiny as [calibrating any signal](https://www.luxalgo.com/library/concept/logistic-signal-calibration/).

### What is the U-matrix on a SOM?

It is a visualization that shades each node by its average distance to neighboring prototypes. Areas of uniformly small distances are regions of similar conditions; ridges of large distances mark the boundaries between distinct condition types. Traders use it to decide where one regime ends and another begins before wiring rules to map regions.

## Related concepts

- Kernel Regression: https://www.luxalgo.com/library/concept/kernel-regression/
- Gaussian Process Regression: https://www.luxalgo.com/library/concept/gaussian-process-regression/
- Kernel Density Estimation: https://www.luxalgo.com/library/concept/kernel-density-estimation/
- Support Vector Machines: https://www.luxalgo.com/library/concept/support-vector-machines/
- Decision Trees: https://www.luxalgo.com/library/concept/decision-trees/
- Gradient Boosting: https://www.luxalgo.com/library/concept/gradient-boosting/
- Random Forest: https://www.luxalgo.com/library/concept/random-forest/
- Neural Networks: https://www.luxalgo.com/library/concept/neural-networks/
- LSTM / Recurrent Networks: https://www.luxalgo.com/library/concept/lstm-recurrent-networks/
- Bayesian Classifiers: https://www.luxalgo.com/library/concept/bayesian-classifiers/

---

Source: https://www.luxalgo.com/library/concept/self-organizing-maps/ (LuxAlgo Library, the encyclopedia of trading & technical analysis). Free to use with attribution: https://www.luxalgo.com/library/license/