title: How to assign a class to an instance using saved model in weka
body: <p>Before I decided to post the problem I'm having I've read a lot of posts and I still couldn't get a clear answer. So here it is:</p>
  
  <p>Using weka I have trained a NaiveBayesTree with my training data that looks like that:</p>
  
  <pre><code>(the values are simplified, and there's 20000 rows in the training set)
  AF3,F7,F3,FC5,T7,T8,FC6,F4,F8,AF4,Action
  -1,2,0,1,0,0,-1,-0,-0,-0,NEUTRAL
  -2,1,0,2,-0,0,-0,0,-1,-0,RIGHT
  -1,1,0,2,-0,0,-1,0,-1,-0,LEFT
  </code></pre>
  
  <p>Now I would like to use the saved model in my program to determine what is the class distribution in the given 128 rows of test data. For this 128 rows I do not have the classes (Action attribute) assigned. Basically I would like the model to answer that :) </p>
  
  <p>So the test rows looks like this:</p>
  
  <pre><code>-1,1,0,2,-0,0,-1,0,-1,-0,?
  </code></pre>
  
  <p>So far I've came up with this code:</p>
  
  <pre><code>Classifier nbTree = (Classifier)SerializationHelper.read(Model) as NBTree;
  Instances testInstances = TestSet();
  testInstances.setClassIndex(10);
  
  for (int i = 0; i &lt; testInstances.numInstances(); i++)
  {
      Instance instance = testInstances.instance(i);
      double assignedClass = nbTree.classifyInstance(instance);
      double[] distributionForInstance = nbTree.distributionForInstance(instance);
  }
  </code></pre>
  
  <p>But it will always generate 0 for each assignedClass and distributionForInstance will always have exactly one element with different values:</p>
  
  <pre><code>0,9412543332996
  0,9412543332996
  0,9412543332996
  0,9412543332996
  0,0577106296809467
  0,315216251505317
  0,9412543332996
  0,9412543332996
  0,315216251505317
  0,315216251505317
  0,863366140658458
  0,9412543332996
  0,9412543332996
  0,9412543332996
  0,9412543332996
  0,783615619462732
  </code></pre>
  
  <p>I walking in circles fro two days now and would really appreciate some help :)</p>