Glossary
96 terms from Unsupervised Learning, in plain words, each with the chapter that teaches it.
A
- adjusted Rand index (ARI)
- A score for how much two clusterings agree, judged over every pair of customers: do both put them together or apart? It is 1 for identical groupings, whatever the numbering, and about 0 for agreement no better than chance.
- agglomerative clustering
- The common kind of hierarchical clustering. It starts with every row as its own cluster and repeatedly merges the two closest clusters until one remains.
- anomaly
- A row that is unlike the others, such as a 3 a.m. $300 order from a brand-new customer. Unusual does not always mean wrong: a new café ordering in bulk is good news.
- anomaly detection
- Ranking rows by how rare or strange they are, with no labels saying which ones are bad. It produces a list; people decide what is actually wrong.
- artifact
- A pattern created by how a column is computed rather than by real behavior. For example, a coupon rate from one order can only be 0 or 1, which splits one-order customers into two useless piles.
- assigning new rows
- Placing new customers into an existing clustering by calling `predict` after `prep.transform` (never `fit_transform`, which would change the scale). Only k-means, Gaussian mixtures and UMAP can do this; hierarchical clustering, DBSCAN, HDBSCAN and t-SNE cannot.
B
- BIC (Bayesian information criterion)
- A score for a probability model such as a Gaussian mixture that rewards fitting the data well and penalizes extra parameters; lower is better. It gives an opinion on the number of components, not a verdict, and the best number can shift with settings such as `reg_covar`.
- bootstrapping
- Drawing a new sample of rows with replacement, so some customers appear twice and some not at all, then refitting on it. It shows how much a result depends on which customers happened to be in the data.
- border point
- In DBSCAN, a non-core point that lies within `eps` of a core point and so joins that point's cluster.
C
- catch-all cluster
- A cluster that collects messages or rows that fit nowhere else, like Priya's 26 'mixed' messages. Read it by hand before reporting counts.
- center (centroid)
- The average of a cluster's rows, a 'typical member'. k-means assigns each row to the nearest center and then moves each center to the mean of its rows.
- cluster
- A group of rows that are more alike than rows in other groups. Clustering is the act of finding such groups, for example types of Kettle & Crane customers.
- cluster profile
- A table that describes each cluster in the original units, such as median days since last order and median spend. It is how you see what makes each group different and give it a name.
- ColumnTransformer
- A scikit-learn tool that applies different preparation steps to different columns, such as log-and-scale for money and plain scaling for the rest. It can combine these steps into one reusable preparation step, like the `prep` used for the Kettle & Crane customer data.
- component (Gaussian mixture)
- One of the overlapping bell-shaped distributions in a Gaussian mixture, standing for one cluster, with its own center, covariance and weight. (In PCA, 'component' instead means a direction of spread.)
- compression
- One of the four jobs of unsupervised learning: replacing many columns with a few that carry most of the information, such as ten features squeezed into three. PCA is the standard tool for it.
- contamination
- An Isolation Forest setting for the share of rows you expect to be anomalies. It decides where the flag line is drawn, so contamination=0.01 flags the strangest 1% of orders.
- control group
- A random part of a segment, such as 10%, held back from a campaign. Comparing it with the treated customers shows the campaign's real effect.
- core point
- In DBSCAN, a point that has at least `min_samples` points (counting itself) within `eps`. Core points within `eps` of each other join the same cluster, which lets clusters follow any shape.
- cosine distance
- 1 minus the cosine similarity. It compares the direction of two rows, such as which words two messages use, rather than their size or length.
- covariance
- The spread and shape of a Gaussian component, such as whether it is round or a tilted ellipse. In scikit-learn, `covariance_type` sets how flexible the shapes may be: 'full', 'diag', 'tied' or 'spherical'.
- crosstab
- A pandas function (`pd.crosstab`) that counts how many rows fall into each pair of categories. It is used to compare two clusterings, or to compare segments against a column such as `channel`.
D
- DataFrame
- The pandas table type that holds data in rows and named columns. A CSV file such as customers.csv is typically loaded into a DataFrame with `pd.read_csv`.
- DBSCAN (density-based spatial clustering of applications with noise)
- A clustering method that grows clusters through crowded neighborhoods, so clusters can have any shape. Isolated points are labeled noise (−1) instead of being forced into a cluster.
- dendrogram
- A tree diagram that draws the history of merges in hierarchical clustering. The height where two branches join is the distance at which they merged, and long gaps suggest natural places to cut.
E
- elbow
- The bend in a plot of inertia against k, where adding another cluster stops buying much tightness. Real elbows are often soft and need support from silhouettes and business sense.
- embedding
- A low-dimensional map of the rows, such as the 2D layout from t-SNE or UMAP, that keeps each point's neighbors close. The term also covers text embeddings, which are numeric vectors that capture meaning.
- eps
- The DBSCAN setting for the radius of a point's neighborhood, in the same units as the data. Too small shatters clusters into pieces and too large merges them.
- Euclidean distance
- The straight-line distance between two points: square the difference in each column, add them up and take the square root.
- explained variance ratio
- Each principal component's share of the data's total spread. Adding them up with `cumsum()` shows how much the first few components keep, such as 94.5% for four.
F
- fcluster
- A SciPy function that cuts a hierarchical-clustering tree into groups, either at most `t` groups (`maxclust`) or at a chosen height (`distance`). Group numbers start at 1.
- feature
- A column that describes each row, such as recency_days or spend_12m. Unsupervised methods group rows using only the features you give them, so choosing features deserves the most thought.
- feature weighting
- Deciding how much each column counts in a distance. After standardizing every column counts equally, so to make one matter more you multiply its scaled column by a number such as 2, on purpose.
- FunctionTransformer
- A scikit-learn tool that wraps any function, here `np.log1p`, so it can sit inside a pipeline. `feature_names_out="one-to-one"` tells it the column names do not change.
G
- Gaussian mixture model (GMM)
- A soft clustering method that assumes the data came from several overlapping bell-shaped distributions (components). It gives each customer a probability of belonging to each one and can fit stretched, tilted clusters.
- Google Colab
- A free service that runs Python notebooks in your web browser, so you need no local setup. As of October 2026 it ships older scikit-learn and pandas, so you may need to upgrade them.
- groupby
- A pandas command that splits a table into groups, such as by channel or cluster, so you can compute something like the median for each group.
H
- hard and soft clustering
- A hard clustering puts each row in exactly one cluster, like k-means. A soft clustering gives each row a probability for every cluster, such as 61% regular and 39% deal seeker.
- HDBSCAN (hierarchical DBSCAN)
- A version of DBSCAN that effectively tries every `eps` and keeps the clusters that last longest, so it handles areas of different density. Its main setting is `min_cluster_size`, and it gives each point a membership strength.
- hierarchical clustering
- Clustering that builds a tree of merges, starting from single rows and joining the closest groups step by step. You do not choose k up front and can cut the tree wherever you like afterward.
I
- index
- A segment's average divided by the overall average, times 100. 100 means average, 200 double and 50 half, so you can see at a glance what makes each segment different.
- inertia
- The sum, over all rows, of the squared distance to their own cluster center. Lower means tighter clusters, but it always falls as k grows.
- Isolation Forest
- Anomaly detection that builds many random trees and scores each row by how few random splits isolate it, so odd rows score high. It needs no scaling.
J
- joblib
- A Python library used to save fitted objects, such as the preparation step and k-means model, to a file and load them back later. Only load such files from sources you trust.
K
- k-distance plot
- A plot of each point's sorted distance to its k-th nearest neighbor. The bend where noise begins is a classic choice for DBSCAN's `eps`.
- k-means
- A clustering method that splits rows into k clusters you choose. It assigns each row to the nearest center, moves each center to the mean of its rows and repeats until nothing changes.
- k-means++
- The default way scikit-learn picks k-means' starting centers. Each new center is chosen with a probability that grows with its distance from those already picked, so starts are spread out and bad runs are less likely.
L
- label
- The known answer attached to a row in supervised learning, such as whether a subscriber canceled; unsupervised learning has none. (`labels_` in scikit-learn instead holds the cluster number each row was assigned.)
- likelihood
- How probable the observed data is under a model. Fitting a Gaussian mixture finds the components that make the data most likely.
- linkage
- The rule for the distance between two groups of rows in hierarchical clustering. Ward adds the least spread, complete uses the farthest pair, average uses all pairs and single uses the closest pair, which tends to chain.
- loadings
- The weights that define a principal component in terms of the original columns. The biggest positive and negative loadings tell you what the component means, such as 'active coffee buyer'.
- local minimum
- A result that no single round of k-means can improve, though it is not always the best possible. Unlucky starting centers can leave k-means stuck in a poor one.
- Local Outlier Factor (LOF)
- Anomaly detection that compares a row's local density with its neighbors' densities: a row in a sparse spot among dense neighbors gets a high factor, and about 1 is normal. It uses distances, so scale first.
- log transform
- Taking the logarithm of a skewed column so that ratios become equal differences, such as $10 to $100 counting as much as $100 to $1,000. `np.log1p(x)` computes log(1 + x), so it works for zero too.
M
- MAD (median absolute deviation)
- The median distance of values from their median. It measures spread without being dragged by outliers, which is why robust z-scores use it.
- marketing and privacy rules (CAN-SPAM, CCPA)
- Rules to respect when using segments: CAN-SPAM, the US law for marketing email (working unsubscribe link, honest subject line), and California's CCPA, which gives customers rights over their personal data. Segments should also avoid sensitive information such as health or ethnicity.
- min_cluster_size
- HDBSCAN's main setting: the smallest group of points you would call a cluster.
- min_df
- A TF-IDF setting that drops words appearing in fewer than that many messages. With min_df=2, words found in only one message are ignored.
- min_dist
- A UMAP setting for how tightly points may pack together on the map: 0 gives dense clumps and 0.5 a more even spread.
- min_samples
- DBSCAN's setting for how many points, counting the point itself, a neighborhood needs to count as crowded.
- MiniBatchKMeans
- A faster version of k-means for millions of rows. It updates the centers from small random batches and is nearly as good.
- MinMaxScaler and RobustScaler
- Two alternatives to StandardScaler: `MinMaxScaler` squeezes each column into 0 to 1 (good for shares), and `RobustScaler` uses the median and middle 50% of values so outliers you cannot remove do not set the scale.
N
- n_init
- The number of times k-means (or a Gaussian mixture) runs from different starting points, keeping the best run. A value such as `n_init=10` for k-means costs ten times the work of a single run but makes a poor start less likely.
- n_neighbors
- How many neighbors a method looks at. In UMAP small values focus on fine local detail and large ones on the overall layout; in LOF it is how many nearby rows each order is compared with; in `NearestNeighbors` it is how many rows to return.
- nearest neighbors
- The rows closest to a given row. In scikit-learn, `NearestNeighbors` and its `kneighbors` method return the distances and positions of the closest rows, starting with the row itself, which can be used to find lookalike customers.
- noise
- Points that density-based clustering leaves out of every cluster, labeled −1. Noise is not an error: it can be a business decision, like which delivery addresses are not worth a rider.
- novelty
- A Local Outlier Factor option that lets you fit on past orders and then score new ones with `score_samples`. Without it, LOF has no `predict`.
- numba
- A compiler that speeds up Python code. UMAP depends on it, which is why the first UMAP run is slow while it compiles.
O
- one-hot encoding
- Turning a text category such as channel into one 0/1 column per category. In a distance it adds a fixed jump for every mismatch, which can split the data by that column alone.
P
- pairwise_distances
- A scikit-learn function that returns a grid where row i, column j is the distance from row i to row j. It shows directly how scaling can change which customers look alike.
- PCA (principal component analysis)
- A method that finds the directions along which the data spreads most and describes each row by its coordinates (scores) along them. It draws a 2D map or compresses many columns into a few, and needs scaled data.
- perplexity
- t-SNE's main setting, roughly how many neighbors each point pays attention to. Typical values are 5 to 50, and a low value can shatter the data into many fragments.
- principal component
- One of the directions PCA finds: the first captures the most spread, the second the most of what is left at right angles to it, and so on. A row's coordinates along them are its scores.
Q
- quantile
- The value below which a given share of the data falls, such as the 75th percentile. For example, the 75th to 90th percentile of neighbor distances can serve as a starting `eps` for DBSCAN.
R
- random_state
- A setting that fixes the random choices a method makes, so you get the same clusters, with the same numbers, every time. It should be set on any method that uses randomness so results are repeatable.
- reconstruction error
- What compression loses: the average squared difference between the original columns and the ones rebuilt from the compressed version. Rows that compress badly are unusual, so it can also work as an anomaly score.
- reg_covar
- A Gaussian mixture setting that adds a small amount to every component's variance so none can collapse onto a pile of identical values. The number of components BIC prefers changes with it.
- RFM (recency, frequency, monetary)
- The classic retail features: recency (days since last order), frequency (number of orders) and monetary value (dollars spent). Kettle & Crane's customers file has all three plus habit columns.
- robust z-score
- A z-score built from the median and MAD instead of the mean and standard deviation, so big outliers cannot hide smaller ones. The usual cut-off is 3.5.
S
- scaling (standardizing)
- Putting columns on equal terms by subtracting each column's mean and dividing by its standard deviation, as StandardScaler does. Without it, a column with big numbers, like dollars, dominates every distance.
- segment
- A cluster that the business has named and uses, such as Kettle & Crane's 'gift buyers'. Segmentation, grouping similar rows, is one of the four jobs of unsupervised learning.
- shrinkage
- Pulling a rate based on few events toward the overall average, for example by pretending each customer also placed 3 average orders. It stops one-order customers from getting extreme coupon rates of 0 or 1.
- silhouette
- How much closer a row is to its own cluster than to the nearest other cluster, from −1 to 1: near 1 is well placed, near 0 on a border, negative probably misplaced. Averaged over all rows, it helps compare values of k.
- skewed
- Lopsided, with a long tail of large values, like Kettle & Crane's spending where a few big spenders pull the mean far above the median. Skewness measures it: 0 is symmetric and above 1 is strongly right-skewed.
- sparse matrix
- A table that stores only its non-zero values. TF-IDF produces one because each message uses only a few of the vocabulary's words.
- stability
- Whether you get the same segments with a different random seed or a slightly different set of customers. Unstable segments are not worth building campaigns on.
- stop words
- Words removed before analyzing text because they carry no topic, such as 'the' or 'can'. You can add your own, like greetings and signatures such as 'hi' or 'Dana'.
- supervised learning
- Machine learning where every example comes with a label, the known answer, and the model learns to predict it. Unsupervised learning is the case with no such column.
T
- t-SNE (t-distributed stochastic neighbor embedding)
- A mapping method that places points in 2D so each point's nearest neighbors stay its neighbors. It distorts island sizes and gaps, changes with settings and seeds, and cannot place new rows.
- TF-IDF (term frequency times inverse document frequency)
- A word score that is high for words frequent in one message but rare across all messages, so 'coupon' scores high and 'the' near zero. It turns each message into a row of numbers that k-means can group.
- trustworthiness
- A check on a map: of each point's nearest neighbors on the map, how many were really near it in the original data (1.0 means none are impostors). It says nothing about island sizes or gaps.
U
- UMAP (uniform manifold approximation and projection)
- A mapping method like t-SNE that keeps each point's neighbors close, but it is faster and can place new rows with `transform`. It comes from the separate `umap-learn` package.
- unsupervised learning
- Finding structure in data without labels. You give it features and no target, and it returns groups, directions, maps or scores that you then interpret.
V
- vocabulary
- The set of words kept after filtering, which become the columns of the TF-IDF matrix. Stop words and `min_df` shrink it, here to 105 words and later 94.
W
- Ward linkage
- A linkage rule for hierarchical clustering that merges the two groups whose merger adds the least within-cluster spread. It gives compact, similar-sized groups, works only with Euclidean distance and is the usual default.
Z
- z-score
- How many standard deviations a value is from the mean. Flagging values beyond 3 is the simplest one-column outlier check.