## Friday, 20 February 2015

### some simple similar[op] examples

In this post just a few simple examples of similar. More interesting examples in future posts.

First, say we know a little about oranges. We know their taste, their smell, their colour, and their size. And say we know those operators for other objects too. Then, in an English like way, we can ask:
```similar[taste] |orange>
similar[smell] |orange>
similar[colour] |orange>
similar[size] |orange>
```
and we should get back expected results. Now, how about a working example?
```-- learn some toy knowledge about disease symptoms:
disease-symptoms |disease: 1> => |symptom: a> + |symptom: b> + |symptom: c>
disease-symptoms |disease: 2> => |symptom: d> + |symptom: e>
disease-symptoms |disease: 3> => |symptom: f> + |symptom: g> + |symptom: h> + |symptom: i>
disease-symptoms |disease: 4> => |symptom: j> + |symptom: k> + |symptom: l>

-- learn some symptoms of a new patient:
disease-symptoms |patient: 1> => |symptom: b> + |symptom: h> + |symptom: f> + |symptom: k>

-- now ask, and see what the possible disease is for our patient?
-- and the 100 is in there to convert it to percent
sa: 100 similar[disease-symptoms] |patient: 1>
50.000|disease: 3> + 25.000|disease: 1> + 25.000|disease: 4>
```
So 50% chance of disease 3, and 25% for disease 1 and 4.

Now, another example. Say a shopping centre keeps track of all your purchases (heh, not a big stretch!). Now, given a new shopping basket just rung up, can we guess who it might be? Yup.
```-- this is what the shop knows:
basket |user 1> => |milk> + |bread> + |tea> + |bananas> + |carrots> + |chocolate>
basket |user 2> => 4|apple> + |milk> + |coffee> + |steak>
basket |user 3> => |chocolate> + |vegemite> + |olive oil> + |pizza> + |cheese>

-- a new basket has just been processed:
basket |f> => 3|apple> + 5|oranges> + |milk> + |bread> + |coffee> + |steak>

-- now ask, which user is this likely to be?