0

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,...}.

Margus
  • 1,987
  • 2
  • 15
  • 19
  • 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 332*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 09:45
  • See the answer of a similar question: http://mathematica.stackexchange.com/questions/75801/creating-identification-classification-trees – Anton Antonov Sep 21 '15 at 15:38

1 Answers1

2

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

Rojo
  • 42,601
  • 7
  • 96
  • 188