What I built eight small experiments in artificial intelligence

These are eight little programs I wrote to teach myself how artificial intelligence really works. Each one is a different kind of learning machine, written from scratch in plain JavaScript — no shortcuts, no libraries. Give one of them a few examples and it learns: it builds up its own idea of what a digit looks like, or what makes a star a star, or which words tend to show up in junk mail. The maths is simple; it is only the patience of the machine that makes it look clever.

live Digit recognition

digit recognizer

Draw a digit by hand. The network watches as you write and tries to read what you wrote.

html · css · js »
live Pair-matching

Whose handwriting is this?

Register a few writers. The network learns each one's style fingerprint, then identifies any new sample by comparison.

html · css · js »
live Image classifier

tiny CNN

A small image classifier built from scratch. Define your own categories, draw a few examples, and watch the network learn.

html · css · js »
live Sketch guesser

quick draw clone

Doodle something on the canvas. The network races you to guess what it is before you have finished drawing.

html · css · js »
live Sketch matcher

doodle to emoji

Draw any of 24 things — a star, a tree, a cloud, a fish — and the network picks the closest match.

html · css · js »
live Game-playing AI

RPS mind reader

Rock, paper, scissors against a computer that quietly learns your habits and starts winning.

html · css · js »
live Text classifier

spam filter

Show it a few examples of spam and a few normal mails. The classic Bayesian filter from the early days of the internet.

html · css · js »
live OCR

plate reader

Upload a photo of a number plate. The program walks through grayscale, threshold, segmentation and template matching, and reads the plate.

html · css · js »