ML Examples
Classification example: purchase yes/no
The cheat sheet’s logistic-regression example uses features such as user age, user income, and user gender to predict whether a user purchases something. The model can output
A threshold such as converts the probability into yes/no. If false positives are expensive, raise the threshold; if missed purchases are expensive, lower it.
Classification example: bacteria vs virus
The LDA example in the PDF shows medical features such as CRP and temperature. LDA finds a linear discriminant score that separates bacteria from virus as well as possible. The important idea is projection: turn several measured features into a score where classes separate more cleanly.
Classification example: Naive Bayes
Suppose an email contains words such as “winner”, “invoice”, and “meeting”. Naive Bayes estimates the probability of each class using and the class prior . It then chooses the most probable class. It is called naive because it treats features as conditionally independent once the class is known.
Regression example: house price vs size
The cheat sheet’s linear-regression example is a fitted line plot with price as the dependent variable and size as the independent variable. A simple model is
If residuals are roughly random, the line may be adequate. If residuals curve, a polynomial or tree-based model may be better. If large outliers dominate the line, use robust checks or transformations.
Polynomial regression example
If price increases slowly for small houses but rapidly for large houses, a straight line may underfit. A quadratic model
\widehat{ ext{price}}=eta_0+eta_1x+eta_2x^2can capture curvature. The danger is going too high degree and fitting noise rather than structure.
Gaussian-process regression example
The PDF’s GPR sketch shows a function like , observations, a prediction curve, and a 95% confidence interval. The useful feature is not just the predicted mean; it is knowing where the model is uncertain. That is based for scientific modelling, where “how sure are we?” is often as important as the point prediction.
KNN example
For a point near labelled clusters Class A, Class B, and Class C, KNN checks the nearest neighbours. If most of the nearest neighbours are Class B, classification predicts Class B. For regression, if the nearest neighbours have values , KNN with predicts .
Tree and forest example
A decision tree for house prices might first split on size, then location, then age. A regression leaf stores the average price of houses in that region. A random forest trains many such trees on randomised samples and averages their predictions, reducing the instability of one tree.
Boosting example
Start with a weak tree that underpredicts expensive houses. The next tree is trained to correct those residuals. Repeating this produces an additive model that can fit complex patterns. The same idea works for classification: later weak classifiers focus on mistakes from earlier ones.
Regularisation example: Lasso vs Ridge
Imagine predicting sales from adverts on TV, search, social, and print. Lasso may set the print coefficient to zero if it adds little predictive value, acting like feature selection. Ridge keeps all features but shrinks their coefficients, which helps when advertising channels are correlated.
Physics-informed example
In a PINN-style model, a neural network predicts a field, but the loss includes both data mismatch and equation residuals. Residuals in NF2 and PINNs is an example in solar physics: the network should fit observations while respecting physical constraints such as force-free or solenoidal magnetic fields.