Find structure in unlabelled features: distinguish grouping from prediction, calculate a simple clustering fit, and recognise the choices behind the geometry.
Unsupervised learning
Unsupervised learning finds structure in observed features without using supplied outcome labels to guide that fit. In quantitative finance, it can help organise assets with similar characteristics or compress a panel of market measurements. Finding a pattern gives a researcher something to investigate; it does not by itself establish a return forecast or a trading opportunity.
In supervised learning, training examples pair features with a target, such as a subsequent return or a default indicator. An unsupervised fit instead uses the feature observations themselves. An algorithm may produce group labels, latent coordinates or a fitted density, but those outputs are different from target labels supplied before fitting.
Several kinds of structure
Clustering groups observations according to a chosen notion of similarity. For example, a researcher might seek peer groups of assets using historical return characteristics. The groups depend on what was measured and how similarity was defined.
Principal component analysis is a different unsupervised method: it constructs directions that summarise variation in the features. A low-dimensional representation can help visualise a correlated market-data panel without assigning each row to a discrete group. Density estimation and some anomaly-detection methods also fit within unsupervised learning; clustering is one branch of the broader family. The scikit-learn guide separates these tasks.
The absence of outcome labels does not mean the absence of modelling choices. Feature construction, sample selection, scaling, distance measures and model complexity all shape the result.
Four values, two fitted groups
Consider an original synthetic, univariate example. Four observations have scalar feature values 0,1,9,10, in arbitrary units. No target labels are supplied. Choose two nonempty clusters and use the k-means squared Euclidean distance objective. For the partition A={0,1} and B={9,10}, the fitted centres are their means:
μA=20+1=0.5,μB=29+10=9.5.
Each observation lies 0.5 feature units from its assigned centre. The total within-cluster sum of squared distances is
J=(0−0.5)2+(1−0.5)2+(9−9.5)2+(10−9.5)2=1.
The value 1 has squared feature units. It is a total, rather than an average loss or an accuracy percentage. The names A and B are arbitrary: swapping them leaves the grouping and its objective unchanged. Neither name was an observed answer used to train the model.
Four synthetic scalar features, 0, 1, 9 and 10, are grouped into A containing 0 and 1 and B containing 9 and 10. Hollow diamonds mark centres 0.5 and 9.5. Each observation is 0.5 units from its centre, giving total squared distance 1.
Original univariate example in arbitrary feature units. Filled circles are observations; hollow diamonds are fitted centres. Group names A and B are outputs, with no supplied target labels. Squared distances have squared feature units.
K-means alternates between assigning observations to their nearest centre and replacing each centre with its group's mean. Our calculation describes the displayed partition. In larger problems, the iterative algorithm can finish at different local minima from different starting points; repeated initialisations help search for a better fit. A smaller squared-distance objective measures a tighter geometric fit, not a more profitable investment rule. The k-means documentation explains the objective and its assumptions.
For the algorithm and its optimisation interpretation, continue to k-Means Clustering. The full lesson requires membership, with a public preview.
The geometry is part of the model
This example has only one feature. Multiplying every value by the same nonzero constant preserves the k-means objective's ranking of partitions while changing the scale of the objective. With several features, however, rescaling just one feature changes its relative contribution to Euclidean distance and can change the groups.
Combining a dollar-valued characteristic with a percentage-valued characteristic therefore requires an explicit scaling decision. Standardisation can put features on comparable numerical scales, but it also changes the question the distance measure asks. It does not establish which features deserve economic importance. Outliers, the observation window and the chosen number of groups can also materially affect the result.
A cluster is a hypothesis about the data
A group of similar historical observations is not automatically a true market regime, a causal explanation or a signal that can be traded in real time. Check whether the interpretation survives reasonable feature and scaling choices, changes of sample and later data. Stability helps assess reproducibility, but a stable grouping can still be economically unhelpful.
Unsupervised fitting also remains vulnerable to look-ahead bias. If a historical trading decision uses centres or principal components fitted with later observations, future feature information has entered the decision even though no return labels were supplied. For a forecasting or trading evaluation, fit scaling and the unsupervised transformation using information available at the simulated decision time, then apply the fitted transformation to later observations. The scikit-learn leakage guide explains why preprocessing must respect the training/test boundary.
If a cluster assignment becomes an input to a return-prediction model, that later stage can be supervised. It needs its own evaluation on later data and an assessment of transaction costs. The clustering objective alone supplies neither.
Sources
Gareth James, Daniela Witten, Trevor Hastie and Robert Tibshirani, An Introduction to Statistical Learning with Applications in R, 2nd edition (2021), §2.1.4, pp. 26–27; §12.1–12.2, pp. 497–499; §12.4–12.4.1, pp. 516–520; and §12.4.3, pp. 530–532. The authors' site provides the text.