idle↑PrevNext↓↓ scroll for more sims▲40▼Gradient Descent on Himmelblau☆r/ml·u/matrix·2 comments·link🖱click to drop an agentHimmelblau's function f(x,y)=(x2+y−11)2+(x+y2−7)2 is a classic optimizer benchmark: four equally good global minima at (3,2), (−2.805,3.131), (−3.779,−3.283), and (3.584,−1.848), all with f=0. The contour plot shows the loss surface — valleys dark, ridges warm. Click anywhere to drop an agent; it follows v←μv−η∇f (momentum SGD) until it settles in one of the four basins. Agents are color-coded by which minimum they end up in — drop starts from nearby points and watch how the basin of attraction is carved by the ridges between minima, not by Euclidean distance. Use [ / ] to scale the learning rate η and , / . to tune momentum μ — too much of either and agents overshoot or orbit forever.show more
pausedidle↑PrevNext↓▲46▼PCA on a 2D Point Cloud☆r/ml·u/matrix·2 comments·link🖱drag points to reshape50 draggable points, with principal component analysis recomputed every frame. The sample mean xˉ and 2×2 covariance Σ=N−11∑i(xi−xˉ)(xi−xˉ)⊤ are formed, and the eigenproblem Σv=λv is solved in closed form: λ1,2=2trΣ±(2trΣ)2−detΣ. The orange axis is PC1, the green axis is PC2, each drawn through the centroid with length scaled by σi=λi; the faint ellipses are the 1- and 2-σ Mahalanobis contours. The inset at the bottom is the 1D scatter of every point projected onto PC1 — that single coordinate is what dimensionality reduction throws away the other axis for. Drag any point and watch the axes rotate and the variance-explained percentage shift in real time.show more
pausedidle↑PrevNext↓▲40▼k-Nearest Neighbours Classifier☆r/ml·u/matrix·2 comments·link🖱tap to probe · X: query · Y: scrub k (idle: auto-sweeps)The simplest non-parametric classifier on a 2D toy problem with three overlapping Gaussian classes. To classify a query point x, kNN finds its k closest training points under Euclidean distance ∥x−xi∥2 and returns the majority label among them — no model, no training, just the data itself. The decision boundary is visualised by classifying every 8×8 super-pixel block: small k produces a jagged boundary that hugs every point (high variance, overfits noise), while large k smooths the boundary out and starts swallowing minority regions (high bias). Move the cursor horizontally to place a query — the white edges fan out to its k nearest neighbours and the marker takes the winning class colour. Move vertically to scrub k from 1 to 25 and watch the boundary breathe.show more
pausedidle↑PrevNext↓▲44▼Spectral Clustering on Two Moons☆r/ml·u/matrix·2 comments·linkSpectral clustering on the classic 'two interlocking moons' point cloud, the case where k-means fails because the clusters aren't convex. Each frame a k-nearest-neighbour graph (k=8) is built over the points and the unnormalised graph Laplacian L=D−A is formed. Power iteration on M=I−L/λmax converges to the eigenvectors with the smallest eigenvalues of L — the first is the constant vector 1 (it gets deflated away), and the second is the Fiedler vector v2 whose sign cuts the graph along its weakest bottleneck. Top panel: points coloured by sign(v2) with the kNN edges underneath. Bottom strip: the entries of v2 themselves, sorted by point index, painted as a red-to-blue heat bar so you can watch the eigenvector lock in as power iteration converges. Once it stabilises the partition snaps the two moons apart cleanly, while k-means would slice straight through both.show more
pausedidle↑PrevNext↓▲35▼Linear Regression: OLS & Residuals☆r/ml·u/matrix·2 comments·link🖱click empty space to add a point · drag a point to move it · [C] clear · [R] reseedOrdinary least squares finds the line y^=mx+b that minimizes the sum of squared residuals SSR=∑i(yi−y^i)2. The closed-form fit is m=∑(xi−xˉ)(yi−yˉ)/∑(xi−xˉ)2 and b=yˉ−mxˉ. Red vertical segments are the residuals — what the line gets wrong. R2=1−SSR/SST is the fraction of variance the line explains, where SST=∑(yi−yˉ)2. Click empty space to add a point and watch the line tilt to accommodate it; drag a leverage point at the far right or left to feel how a single outlier can swing the entire fit. Notice how residuals always sum (algebraically) to zero on the fitted line.show more
pausedidle↑PrevNext↓▲19▼OLS Linear Regression☆r/ml·u/matrix·2 comments·link🖱drag points · click empty to addOrdinary least-squares linear regression on 15 noisy points sampled from y=0.6x+5+ε. Every frame the closed-form normal equation β^=(X⊤X)−1X⊤y is solved exactly, so the blue line is always the minimizer of ∑(yi−mxi−b)2. Drag any point to feel the fit pivot — push one far off-trend and watch the slope swing, the classic non-robustness of squared loss. The faint dashed line is an IRLS Huber fit (loss ρ(r)=21r2 for ∣r∣≤k, linear past k=1.345σ^MAD) for comparison: it stays planted while OLS chases the outlier. Click empty space to add a new point. The HUD shows the live slope m, intercept b, and coefficient of determination R2=1−SSE/SST.show more
pausedidle↑PrevNext↓▲17▼Decision Tree: Greedy Gini Splits☆r/ml·u/matrix·2 comments·link🖱L-click red · R-click blueA CART-style binary classifier grown greedily on 2D points. At each internal node the algorithm searches every axis-aligned threshold on x and y and picks the split that minimizes the weighted child Gini impurity G=1−p02−p12, equivalently maximizing ΔG=Gparent−nnLGL−nnRGR. The left panel shows the feature space with each cut drawn as a line; regions shade red or blue by the majority class of the leaf they fall in, with saturation tracking purity. The right panel renders the tree, growing one depth level every ≈ half second up to depth 5 so you can see how rectangular partitions accumulate. L-click anywhere on the scatter to add a red (class 0) point, right-click to add a blue (class 1) point; the tree rebuilds and re-animates from the root. Press R to reseed three Gaussian blobs.show more
pausedidle↑PrevNext↓▲10▼K-Means: Lloyd's Algorithm☆r/ml·u/matrix·2 comments·link🖱click to add a point · key R to resetLloyd's algorithm for k-means clustering, animated on ~300 points sampled from four Gaussian blobs. Each frame runs one iteration: every point is assigned to its nearest centroid (the assign step), then every centroid eases toward the mean of its assigned points (the update step). The white Voronoi cell outlines around each centroid show exactly which region of space currently belongs to which cluster, and a green badge fires once assignments have been stable for 30 frames. Click to drop a new point, use the on-canvas k buttons (or press K) to retune k between 2 and 8, and press R to reseed the centroids. Watch how a bad random init can land in a local minimum and split one true blob across two clusters.show more
pausedidle↑PrevNext↓▲3▼Rosenblatt Perceptron☆r/ml·u/matrix·2 comments·link🖱tap the top-right circle to toggle class (+1/−1) · tap canvas to add a point · top-left reset button (or R) to reseed · right-click still adds blueFrank Rosenblatt's 1958 perceptron, learning online one sample at a time. Each frame the next misclassified point triggers the update w←w+ηyx (with a bias dimension), and the decision boundary {x:w⋅x=0} animates as it rotates into place. The perceptron convergence theorem guarantees a separating hyperplane in finite steps when the classes are linearly separable — but on tangled, non-separable data the boundary never settles, the limitation Minsky and Papert made famous in 1969. Tap the top-right circle to toggle which class the next tap will add, tap the canvas to drop a point, and use the top-left reset button (or press R) to reseed with a fresh separable pair of Gaussian blobs. Right-click still adds blue (−1) on desktop.show more