## 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>
```
```sa: then norm similar-input[pattern] split |sunny low no>