programlibs/Learn/demos/blobs.xtl
Learn's four models on one set of points: three blobs of 20 (around 0 0, 6 6 and 0 6, a fixed ripple instead of chance). k-means finds them without their labels; kNN and logistic regression learn them from their labels; PCA finds the direction they spread along most. Run with "just demo-lib Learn blobs".
X : Float
X ← o̲\ 2 60 r̲eshape (cx + 0.8 × s̲in 1.3 × f̲loat i) c̲at cy + 0.8 × c̲os 2.1 × f̲loat i
C : Float
k-means: the three centers found, and which cluster each point is in.
C ← (3, 10) ᵐˡk̲means X
Q : Float
kNN (5 neighbors) and logistic regression on four new points.
Q ← 4 2 r̲eshape 1.0 1.0 5.0 5.0 0.5 5.0 3.0 3.0
mu : Float
PCA: the direction of most spread, and the share of the variance on it.
(mu, V, ev) ← 2 ᵐˡp̲ca X
Used in: mu