Concepts and worked examples
Associations, ensembles, and causal caution
Find item patterns, combine models, and avoid treating correlation as cause.
Association rules describe joint occurrence
Market-basket analysis finds co-occurring items rather than clustering similar customers. A rule A → B describes B among transactions containing A, not a causal effect. Define the transaction boundary: visits, customer lifetimes, and calendar weeks generate different associations.
Consider 100 baskets: 40 contain bread, 30 contain milk, and 20 contain both. The full table is 20 with both, 20 with bread only, 10 with milk only, and 50 with neither. Itemset support for bread is 0.40 and milk is 0.30. Rule support is P(A ∩ B), so support(bread → milk) = 20/100 = 0.20. Confidence = P(B | A) = P(A ∩ B)/P(A) = 20/40 = 0.50.
Association lift = confidence/P(B) = 0.50/0.30 ≈ 1.667. Milk is about 1.667 times as frequent in bread baskets as in all baskets. Under independence, the expected joint proportion is 0.40 × 0.30 = 0.12. Leverage = P(A ∩ B) − P(A)P(B) = 0.20 − 0.12 = 0.08: eight percentage points, or eight baskets above the independence expectation in this sample. Lift is a relative comparison; leverage measures absolute excess frequency.
The reverse rule milk → bread has confidence 20/30 ≈ 0.667, but the same lift and leverage. Confidence is directional; lift and leverage are symmetric for these two events. A lift below 1 indicates less co-occurrence than independence predicts. Undefined denominators, such as an antecedent never observed, must not silently produce useful-looking rules. Also distinguish association lift from cumulative targeting lift in model evaluation: both compare with a baseline, but their denominators and questions differ.
Interesting is not established
High confidence may merely reflect a popular consequent, while two unusual transactions can produce spectacular but unreliable lift. Report counts, support, uncertainty, business relevance, and stability on held-out transactions, not only the largest ratios.
Searching many itemsets creates a multiple-testing problem: some impressive rules appear by chance. Minimum support controls computation and sample size but does not by itself provide false-discovery control. Use suitable multiplicity adjustments where conducting tests, validate selected rules independently, and examine whether seasonality, promotions, store layout, or customer composition explain the pattern. A rule can motivate an experiment or a recommendation candidate; it does not prove that increasing bread purchases would increase milk purchases.
Profiles, graphs, and latent aspects
Profiling describes typical behavior of an individual, segment, or population: transaction timing, spending distribution, or usual service usage. Anomaly detection compares new behavior with an appropriate reference profile. A Gaussian profile's elliptical contours reflect covariance; unusual combinations can matter even when each feature looks ordinary alone. Check seasonal and subgroup differences before treating deviations as suspicious. A profile explains what is typical under a model, not why someone behaved that way.
Graph similarity can rank candidate connections without observed link labels, using common neighbors, neighborhood overlap, or embedding similarity. Supervised link prediction learns from labeled present or future links and appropriately sampled nonlinks. The tasks are related but not interchangeable: a similarity score is not automatically a calibrated probability that a connection will form.
Graph evaluation is particularly vulnerable to leakage. Computing common-neighbor features or embeddings on a graph containing held-out future edges exposes answers. Construct graph features using only information available at the prediction cutoff, remove target edges when necessary, and select splits that reflect new-edge versus new-node deployment. Negative sampling changes class prevalence; metrics and probabilities on an artificially balanced sample do not automatically describe the live candidate pool.
Data reduction compresses observed variables. Matrix factorization can summarize user–item preferences; PCA and SVD can reduce noise and computation. Latent factors are not verified hidden motivations. Compression may lose rare predictive signals despite retaining most variance. Validate downstream usefulness; see PCA and SVD and latent text topics.
Ensembles combine predictors, not miracles
An ensemble combines multiple fitted models through averaging, voting, or a learned combination. The members can be the same model family fitted differently; an ensemble does not require unrelated techniques. Bagging fits models on bootstrap samples and aggregates predictions, often reducing the variance of unstable learners such as deep trees. A random forest adds randomly selected candidate features at each split to reduce similarity among its trees. For classification, averaging probability estimates and voting labels are related but distinct aggregation choices.
For m predictors with equal error variance σ² and equal pairwise error correlation ρ, the average's variance is σ²[ρ + (1 − ρ)/m]. With σ² = 4, ρ = 0.25, and m = 10, it is 4[0.25 + 0.75/10] = 1.30. If errors were uncorrelated, it would be 0.40; if perfectly correlated, it would remain 4. This calculation concerns variance under simplifying assumptions, not the whole prediction error. Shared bias does not disappear by averaging.
Boosting builds an additive model sequentially. Gradient boosting fits each new learner to the negative gradient of the current loss; these are ordinary residuals for squared error, not for every objective. With y = 10 and current prediction 6, the squared-error residual is 4. If the next learner predicts 4 and the learning rate is 0.1, the updated prediction is 6 + 0.1 × 4 = 6.4. AdaBoost instead emphasizes observations through adaptive weighting. Boosting is not merely “fixing bias”: it can affect both bias and variance and overfit noisy labels. Tune learning rate, tree complexity, subsampling, regularization, and stopping rounds using validation.
The noise + bias² + variance decomposition applies to expected squared-error prediction, not unchanged to every classification metric. Bagging often reduces variance; boosting often expands capacity, but neither slogan replaces measurement. Complexity does not inevitably follow a simple bias–variance curve.
Prediction is not intervention
Causal reasoning asks what would happen under an action compared with a counterfactual alternative. For a customer, Y(1) might mean spending with an offer and Y(0) spending without it; the individual effect is Y(1) − Y(0), but only one outcome is observed. Predicting high spending or churn does not identify who benefits from treatment. Confounding occurs when factors influence both treatment assignment and outcome, such as agents preferentially contacting already-engaged customers.
Randomized experiments make treatment assignment independent of potential outcomes in expectation, supporting causal estimation with appropriate analysis, adherence definitions, and uncertainty. Attrition, interference between participants, and limited transportability still matter. Observational causal estimates require assumptions such as exchangeability given measured confounders, positivity, and consistent treatment definitions. Simply training a supervised predictor does not establish those assumptions. Use observational associations to generate hypotheses, and distinguish expected outcomes from incremental treatment effects.
Question: A rare rule has lift 50. Should it drive a promotion?
Not without its counts, confidence interval, multiplicity context, operational value, and independent validation. Then test whether the proposed promotion changes outcomes rather than assuming the association is causal.
Question: Why might a hundred trees repeat the same mistake?
They may share missing information, correlated features, biased labels, or systematic error. Randomization can reduce correlation but cannot create absent signal or eliminate shared bias.
Connect these ideas to honest model selection and expected-value decisions.