ML on Apple ][+ (mdcramer.github.io)

🤖 AI Summary
A developer/CS229 TA implemented k-means clustering on an Apple II+ in APPLESOFT BASIC as a compact, didactic demo showing the algorithm iterating and the decision boundary being drawn in real time. The post walks through initialization (random distinct seed centroids from the dataset), assignment (compare squared Euclidean distances to avoid expensive SQRT calls), update (recompute centroids as per-cluster means), and convergence (centroid movement threshold DI > 0.01). The program visualizes centroids, connects them, and draws the perpendicular bisector as the decision boundary inside the screen box; it also preserves extreme Gaussian outliers rather than clipping them. The author notes practical Apple II details (PEEK/POKE keystroke wait, array declaration quirks, and screen-coordinate handling). This is significant as an educational artifact: it demonstrates how core ML ideas (distance-based clustering, centroid updates, convergence checks) are simple, portable and easy to visualize even on 1970s hardware, making k-means an effective teaching tool. The implementation highlights useful engineering choices—using squared distances for speed, a special-case accuracy flip for two-class label ambiguity, and centroid bookkeeping (KM, KO arrays)—while also exposing limitations (many routines assume k=2, drawing code can fail if centroids are off-screen, and the accuracy trick doesn’t generalize to k>2). Overall it’s a clear, hands-on example of algorithmic fundamentals and pragmatic trade-offs in constrained environments.
Loading comments...
loading comments...