0
$\begingroup$

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

$\endgroup$
4
  • $\begingroup$ I don't know that I understand your application but can you not use a list of replacement rules directly? $\endgroup$
    – Mr.Wizard
    Oct 22, 2012 at 22:44
  • $\begingroup$ 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. $\endgroup$ Oct 22, 2012 at 23:48
  • $\begingroup$ You mention a decision tree, were you thinking of C4.5 or CART type decision trees ? $\endgroup$ Oct 27, 2012 at 9:45
  • $\begingroup$ See the answer of a similar question: mathematica.stackexchange.com/questions/75801/… $\endgroup$ Sep 21, 2015 at 15:38

1 Answer 1

2
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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