Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want to create expression, that classifies samples ( 4 weather features -> decision).

Example training data:

enter image description here

For the values that i have data for, I can use rules:

fs = {
   {0, 0, 0, 0} -> 1, {2, 1, 0, 0} -> 1, {2, 2, 1, 0} -> 1, {0, 2, 1, 1} -> 1,
   {1, 2, 1, 0} -> 1, {2, 1, 1, 0} -> 1, {1, 1, 1, 1} -> 1, {0, 1, 0, 1} -> 1,
   {0, 0, 1, 0} -> 1, {1, 0, 0, 0} -> 0, {1, 0, 0, 1} -> 0, {2, 2, 1, 1} -> 0,
   {1, 1, 0, 0} -> 0, {2, 1, 0, 1} -> 0};
{2, 1, 0, 1} /. fs

Alternatively I can use table/hashmap:

fs[{0, 0, 0, 0}] = 1;
fs[{2, 1, 0, 0}] = 1;
(*etc.*)
fs[{2, 1, 0, 1}]

How can I compute an estimation decision based on closest* existing sample element(s)?

closeness can be defined by any distance function ex: {euclidean distance,hamming distance,...}.

share|improve this question
    
I don't know that I understand your application but can you not use a list of replacement rules directly? –  Mr.Wizard Oct 22 '12 at 22:44
    
Tally of the feature vectors shows the sample values are unique, so there exist one (or more) functions into the decision space. However, n=14 whereas there are 3*3*2*2=36 presumably possible values of feature vectors - so it's necessary to specify a loss function b/c it is the generalization on unseen data that matters. Otherwise, as Mr.Wizard states, just use example rules directly. –  alancalvitti Oct 22 '12 at 23:48
    
You mention a decision tree, were you thinking of C4.5 or CART type decision trees ? –  image_doctor Oct 27 '12 at 9:45

1 Answer 1

up vote 2 down vote accepted

If I understood correctly, just do, using your fs

classify=Nearest[fs];

or eventually

classify=Nearest[fs, DistanceFunction->distFun]

where distFun can be EuclideanDistance, HammingDistance, .... Then you just do

classify[data]

to get your result

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.