Thursday 14 July 2016

simple if-then machine classifier

So, I just watched "Architecting Predictive Algorithms for Machine Learning" on youtube, a nice intro to machine learning techniques. Anyway, at 16:18 there is a simple machine learning task. In this post I just want to show how we encode this example using if-then machines.

Here is the data (copied from the above youtube clip):
The task is, given a sunny outlook, a low temperature and not windy, predict either play or not play. With just a little typing we can encode the table of data as:
pattern |node 1: 1> => |sunny> + |low> + |yes>
pattern |node 1: 2> => |overcast> + |low> + |yes>
pattern |node 1: 3> => |overcast> + |high> + |no>
pattern |node 1: 4> => |overcast> + |low> + |no>
pattern |node 1: 5> => |rainy> + |low> + |no>
then |node 1: *> => |play>

pattern |node 2: 1> => |sunny> + |high> + |yes>
pattern |node 2: 2> => |sunny> + |high> + |no>
pattern |node 2: 3> => |rainy> + |low> + |yes>
then |node 2: *> => |not play>
which is a simple 2 if-then machine system. Now, let's find its' prediction:
sa: then similar-input[pattern] split |sunny low no>
2.667|play> + 1.333|not play>
So the system is pretty sure that the answer is "play". But, we have 5 play patterns, and 3 not play patterns, this biases the results some what. Here is an easy fix, define a normalization operator:
norm |node 1: *> #=> 1/5 |_self>
norm |node 2: *> #=> 1/3 |_self>
Now, ask the prediction:
sa: then norm similar-input[pattern] split |sunny low no>
0.533|play> + 0.444|not play>
So the best answer is still play.

Some notes:
1) note the if-then machine structure where we have multiple input patterns and one output pattern per machine, cf real neurons. Though neurons can have many thousands of input patterns per neuron! We could too I suppose, but we need to automate the learning some how. I'm not clear how to do that yet.
2) unlike some other machine learning methods, we are not restricted to 2 classes. Just add more if-then machines and you can have as many classes as you like. The only limit would be computing resources.
3) if-then machines are not all that far from my proposed supervised pattern recognition algo.

No comments:

Post a Comment