Several years ago I got Leo a couple of the old How and Why Wonder books that I remembered loving as a child, esp. this one:


He pulls is out from time to time. A while back we did some flowcharting based on a model in this book:


Today he was skimming through it and came across this picture of a learning machine:


He was esp. interested in the “goof” button, and asked me several questions about how it worked, so I decided that it was time to start into machine learning, since he seemed interested.

We started simple, building a learning version of the “animals” game (aka. 20 questions), which is essentially the same thing as EPAM I, Herb Simon and Ed Feigenbaum’s “Elementary Perceiver And Memorizer”. Programmed in the 1960s, EPAM was the earliest computer simulation of a cognitive skill.

First I explained binary decision trees, and we played the game a few times by hand, and then we flowcharted it:


I didn’t feel like breaking out my laptop and going into Lisp, and Leo is used to the iPad, so I downloaded a free BASIC interpreter:


and we started programming from the flowchart.

Leo actually did a bunch of the programming, with LOTS of guidance, as one would expect. I had to create the data structure and although I tried to explain it, that didn’t get very far; it is, admittedly, slightly obscure, but Leo definitely partly understood it because he was appropriately confused that the same array (A$) holds the questions as holds the answers, which is, in fact, very slightly confusing (esp. if you’re a 5 year old!)

After a bunch of false starts and debugging, which is slow in BASIC (esp. if you’re a 5 year old!) we ended up with this program:


Which, ugly as it may be, actually does work:


Tomorrow, Bayesian inference! 🙂