Machine Learning
Fitting the model…
Initializing Sorting Algorithms...
Sorting
Trees
Graphs
Preparing interactive visualizations...
Machine Learning
Fitting the model…
A model is a family of rules with knobs, a loss scores every setting, and learning searches for the lowest score. Watch it happen on numbers small enough to read — every one computed in your browser.
Fit a line to twelve points by hand, then watch gradient descent do it. Learning is a search for the knob settings that make one number — the loss — small.
L(w, b) = (1/n) Σ (w·xᵢ + b − yᵢ)²Gradient DescentFit by SearchDrag the points while gradient descent refits, and watch a ball roll down the real loss bowl in 3D. The normal equations land on the very same line in one step.
θ = (XᵀX)⁻¹ XᵀyWhat Is Machine Learning?Two Routes, One LineDrag an outlier and watch the squared, absolute and Huber fits react differently; then see why classifiers are scored with cross-entropy. The loss decides what "good" means.
MSE = mean(r²), MAE = mean(|r|), CE = −log pLinear RegressionDefine "Good"A probability for every point of the plane, trained live: a linear score squashed by the sigmoid, with the decision boundary where the score is zero.
p = σ(w·x + b) = 1 / (1 + e^−(w·x + b))Loss FunctionsRegression on Log-OddsSlide the polynomial degree on noisy data: training error keeps falling while validation error traces a U. An L2 penalty reins the wild coefficients back in.
min Σ (ŷᵢ − yᵢ)² + λ‖w‖²Linear RegressionBias and Variancek-fold cross-validation, fold by fold, to choose a model honestly — then a data-leakage trap that scores far above chance on pure noise.
CV = (1/k) Σ errorᵢOverfitting and UnderfittingHold Data OutClick anywhere: the k closest examples vote. No training at all — just memory — and the regions repaint as k and the distance metric change.
ŷ = majority label of the k nearest xᵢNorms and Unit VectorsRemember and VoteTry every threshold on every feature, keep the split that leaves the purest groups, and recurse. The plane breaks into boxes, one question at a time.
Gini = 1 − Σ pₖ²Binary Search TreeGreedy SplitsAssign each point to its nearest centre, move each centre to its points' mean, repeat. The objective only ever falls — but a bad start can trap it.
J = Σᵢ ‖xᵢ − μ_c(i)‖²k-Nearest NeighborsAssign and UpdateRotate a 3D cloud, hunt for the direction it spreads most, and flatten it to 2D. The answers are the eigenvectors of its covariance matrix.
C v = λ v, C = XᵀX / (n − 1)Eigenvectors and EigenvaluesDirections of SpreadSlide a threshold and watch the confusion matrix, precision, recall, F1 and the ROC and PR curves move together — and see 95% accuracy that catches nothing.
P = TP / (TP + FP), R = TP / (TP + FN)Logistic RegressionCount the MistakesA model family, a loss and a search. A fitted line, a spam filter and a language model are all that recipe; once it clicks on two knobs, a billion knobs stop being mysterious.
Training error flatters, accuracy misleads on rare classes and leaked data inflates every score. Knowing how to measure on unseen data is what separates a working model from a demo.
Neural networks are this section with more layers: the same losses, the same gradient descent, the same overfitting. Everything after this — transformers included — builds on it.