Business analytics

Unsupervised learning

Find structure without labels: groups of similar rows and the few directions that explain most of the variation.

No answer column here. These methods look for structure on their own: groups of rows that sit close together, and the few directions that carry most of the variation. Columns are put on a common scale first, so a column measured in thousands doesn’t drown one measured in units.

Your data

Choose a table, then the numeric columns to look for structure in. Every section below uses this choice. A table you loaded under Explore appears here too.

Columns to use

k-means

k-means splits the rows into the number of groups you choose, moving each group’s centre until every row sits with its nearest centre. The silhouette score says how cleanly the groups separate.

—silhouette score (−1 to 1; above 0.5 is a clear structure)

How cleanly each number of groups separates
The groups, by their averages
Rows on the first two columns
Highlight group
  • k-means always returns the number of groups you ask for, structure or not; a low silhouette says the groups are a convenient cut, not a discovery.
  • It favours round, similar-sized groups and is pulled by outliers. Results are seeded so they repeat.

Hierarchical clustering

Start with every row on its own and keep merging the two closest groups until one remains. Ward’s method merges whichever pair adds least to the spread inside groups. The tree of merges, a dendrogram, shows every grouping at once: cut it lower for more groups, higher for fewer.

—of the spread lies between the groups at this cut

The dendrogram

Each row is a leaf along the bottom; a join’s height is how much spread that merge added. The dashed line is the cut.

Highlight group
The groups, by their averages

    Principal components

    Principal component analysis finds new axes, each a weighted mix of your columns, ordered by how much of the variation they carry. If the first two carry most of it, a flat map of the rows on those two loses little, and the weights say what each axis means.

    Any column with two values; the rows at its higher value are drawn in colour.

    —of the variation is carried by the first two components

    How much each component carries
    The rows on two components, with each column as an arrow

    Arrows pointing the same way are columns that rise together; a long arrow is a column the two components describe well. Dots near an arrow’s tip are high on that column.

    What each component is made of

    Correlation between each column and each component (−1 to 1). Values beyond ±0.5 are in bold: they say what the component means.

    • Working on the correlation matrix treats every column equally, whatever its units.
    • The sign of a component is arbitrary: flipping every weight describes the same axis. Here each is signed so its largest weight is positive.
    • PCA finds straight-line structure only, and a two-valued column contributes little more than its proportion; components summarise variation, they don’t explain it.

    Sources

    1. Arthur, D. & Vassilvitskii, S. (2007). k-means++: the advantages of careful seeding. SODA. Rousseeuw, P. J. (1987). Silhouettes: a graphical aid to the interpretation and validation of cluster analysis. Journal of Computational and Applied Mathematics 20, 53–65.
    2. Ward, J. H. (1963). Hierarchical grouping to optimize an objective function. Journal of the American Statistical Association 58(301), 236–244. Lance, G. N. & Williams, W. T. (1967). A general theory of classificatory sorting strategies. The Computer Journal 9(4), 373–380.
    3. Hubert, L. & Arabie, P. (1985). Comparing partitions. Journal of Classification 2, 193–218. Jolliffe, I. T. & Cadima, J. (2016). Principal component analysis: a review and recent developments. Philosophical Transactions of the Royal Society A 374, 20150202.
    4. Everything here is computed in your browser. Ward clustering is checked against SciPy, and k-means, the silhouette, the adjusted Rand index and principal components against scikit-learn and NumPy, in the site’s automated tests.
    5. All example datasets are synthetic, generated for this page.