ML — Logistic, NN+Backprop, Ensembles, Density, RNN, Metrics, kNN, Regression, PCA/SVD, Clustering
Ugg turn pile-of-numbers into wise-rock
Machine Learning (ML) — Ugg feed rock a pile of past hunts, rock learn the pattern, rock become a function that guess the future. Inside every seeing-machine (computer vision) sit these same wise-rocks: a softmax head IS logistic regression, a deep filter-stack IS a brain-net.
Three kind of learning-hunt. Supervised — Ugg show question and answer ; two flavor, classification (answer is a bucket: deer or wolf) and regression (answer is a number: how heavy). Unsupervised — only , rock find own groups. Reinforcement — rock poke world for reward; not this cave.
Three piles, no cheat with test
Split hunts three ways. Train pile — fit the weights. Validation pile — tune the knobs (rock size, learn-rate, regularization strength). Test pile — measure final power ONE time. Ugg warn: no tune on test-pile! Peek at test to pick knobs and it becomes another val — no honest guess of new-mammoth power left. Curse of dimensionality: too many numbers per footprint (high ) and all distances look the same, need a mountain of data — kills the nearest-neighbor magic.
Sigmoid-rock: the yes/no hunter
Logistic regression — . The sigmoid squash any number into , a "how-sure." Train with binary cross-entropy — punish confident-and-wrong hard. Ugg warn: no use MSE (square-error) here! Under sigmoid it is bumpy (non-convex) and the gradient dies at the flat ends.
Learn step is clean: — nudge weight by error times input, times step-size . The nasty sigmoid-slope cancels; THAT is why cross-entropy is friend. The decision boundary is a straight line — sigmoid-rock only split what a spear-line splits. Many buckets? Softmax — share belief across classes, add to one.
Stack the rocks: brain-net
One neuron: — weigh, add, bend through activation . Stack into layers = Multilayer Perceptron (MLP). Activations: sigmoid and tanh bend nice but go flat at ends (vanishing gradient — slope die, learning stall). ReLU — fast, sparse, but a neuron can "die"; Leaky-ReLU and GELU keep it alive.
Backpropagation — chain rule walked backward, each step multiply the local slope, push flows from loss back to every weight. Ugg warn: no start weights at zero! All-zero weights make every neuron in a layer identical, they get identical push forever (symmetry), whole layer collapse to one. Fix with random start: Xavier for sigmoid/tanh, Kaiming (He) for ReLU (the 2 pays back the half of neurons ReLU zeroes out).
Six fire-tricks to train faster
(1) Batch Normalization — squeeze each mini-batch of activations to zero-mean unit-variance, then learn scale and shift .(2) higher learn-rate (BN allow it).(3) Dropout — randomly silence fraction of neurons each step; like many rocks voting; turn OFF at hunt-time.(4) shuffle data each pass.(5) less L2 when BN present.(6) decay learn-rate over time. Ugg warn: at hunt-time BN uses the stored running mean/var, NOT the batch — mix that up and machine break in the field.
Many-rock tribe: bagging vs boosting
Bagging (bootstrap aggregating) — draw many samples with replacement, train rocks apart, average → cut variance; Random Forest is the classic. Boosting — rocks in a line, each new one focus on the last one's mistakes → cut bias; AdaBoost is textbook, and Viola-Jones face-finder (2001) used it. Ugg warn: no mix up! Bagging = parallel = kill variance. Boosting = sequential = kill bias.
Guess the berry-cloud: GMM + EM
Gaussian Mixture Model (GMM): — a weighted sum of bell-hills, weights add to one. Train with EM (Expectation-Maximization). E-step: for each point compute responsibility — how much hill owns point . M-step: re-place each hill's center and spread by weighted average. Repeat — likelihood always climbs, but only to a local hill-top, so start matters.
Sequence-rock: RNN and LSTM
RNN: — same weights reused each step, carry memory ; train with BPTT (backprop through time). Trouble: gradient — vanish if small, explode if big. LSTM fix vanish with an additive cell-state highway (three gates: forget, input, output) — this constant error carousel carries memory far back. GRU — two gates, simpler, often as good. For explode: gradient clipping (cap the size).
Count hits and misses: metrics
From TP, FP, TN, FN: Precision (of what Ugg grabbed, how much right), Recall (of all real, how much caught), F1 (harmonic mean). *Ugg warn: F1 is NOT !* Watch precision when a false-alarm costs (spam filter eats a real letter); watch recall when a miss costs (screening misses a real tumor). AP = area under the precision-recall curve, mAP = mean over classes. Ugg warn: on lopsided data ROC look too pretty (many easy TN) — use the PR curve; and plain accuracy is a lie (always-say-no scores 99%).
Lazy hunter, straight line, squeeze
kNN — no training, just store points, guess by vote of the nearest. Small jumpy (variance), big too smooth (bias); keep odd; curse of dimension bites hard. Linear regression , least squares, closed form normal equations — fails when features collinear (can't invert), then use gradient descent. Polynomial regression is still "linear" (linear in ). L1 (Lasso) pushes weights to exact zero → pick features; L2 (Ridge) shrinks smooth, no zero.
Squash the footprint: PCA and SVD
PCA (Principal Component Analysis) — find straight directions of biggest spread: center the data, make covariance , eigen-crack , keep the top- eigenvectors, project; = variance along . Ugg warn: center first! or the top direction just points at the mean. SVD — the ARE the PCA directions, ; more stable (no squaring), and top- = best rank- copy (Eckart–Young). LoRA writes a weight change as thin with — cheap fine-tune of giant rocks, same low-rank spirit. Eigenfaces = PCA on faces.
Group without answers: clustering
k-means — pick centers, assign each point to nearest, move center to the mean, repeat. Four woes: HARD assignment, likes SPHERE clusters, START-sensitive, OUTLIER-sensitive. Fixes: k-means++ (smart spread start), GMM (soft assignment + shapes), k-medoids (outlier-tough). Hierarchical clustering — merge closest pairs bottom-up (agglomerative) or split top-down (divisive) into a dendrogram tree; cut at a height to choose the cluster count. Linkage: single (chains thin), complete, average, Ward.
Ugg remember
- Sigmoid + cross-entropy, step ; never MSE, never zero-init.
- Bagging kills variance (Random Forest); Boosting kills bias (AdaBoost, Viola-Jones).
- EM: E-step responsibilities, M-step weighted re-fit; likelihood only climbs, to a local top.
- , , ; PR curve for lopsided data; precision when a false-alarm hurts, recall when a miss hurts.
- PCA = eigenvectors of covariance (center first!); SVD = the stable same trick; k-means = hard clusters, seed with k-means++.