title: In MATLAB while classifying a training set using WEKA libraries and evaluating, how do you a debug an "ArrayIndexOutofBounds' error?
body: <p>This is my code snippet , which I found as an answer to another question :</p>
  
  <pre><code>fName = 'E:/WEKA/Weka-3-6/data/iris.arff';
  loader = weka.core.converters.ArffLoader();
  loader.setFile(java.io.File(fName));
  data = loader.getDataSet();
  data.setClassIndex(data.numAttributes()-1);
  
  
  fName1 = 'E:/WEKA/Weka-3-6/data/test.arff';
  loader = weka.core.converters.ArffLoader();
  loader.setFile(java.io.File(fName1));
  test = loader.getDataSet();
  test.setClassIndex(data.numAttributes()-1);
  
  %# train a J48 tree
  classifier = weka.classifiers.trees.J48();
  classifier.setOptions( weka.core.Utils.splitOptions('-c last -C 0.25-M    2') );
   classifier.buildClassifier(data);
  
  
  %# classify test instances
  numInst = test.numInstances();
  pred = zeros(numInst,1);
  predProbs = zeros(numInst, data.numClasses());
   for i=1:numInst
   pred(i) = classifier.classifyInstance( test.instance(i-1) );
   predProbs(i,:) = classifier.distributionForInstance( test.instance(i-1)   );
     end
  
     %# evaluation
  
  eval = weka.classifiers.Evaluation(data);
  
  eval.evaluateModel(classifier, test, javaArray('java.lang.Object',1));
  
  fprintf('=== Run information ===\n\n')
  fprintf('Scheme: %s %s\n', ...
  char(classifier.getClass().getName()), ...
  char(weka.core.Utils.joinOptions(classifier.getOptions())) )
  fprintf('Relation: %s\n', char(data.relationName))
  fprintf('Instances: %d\n',data.numInstances)
  fprintf('Attributes: %d\n\n', data.numAttributes)
  
  fprintf('=== Classifier model ===\n\n')
   disp( char(classifier.toString()) )
  
  fprintf('=== Summary ===\n')
  disp( char(eval.toSummaryString()) )
  disp( char(eval.toClassDetailsString()) )
   disp( char(eval.toMatrixString()) )
  </code></pre>
  
  <p>I tried executing the above code snippet, and a java exception is being thrown the error message is :</p>
  
  <pre><code>"Java exception occurred:
   java.lang.ArrayIndexOutOfBoundsException: 1
  
   at weka.classifiers.Evaluation.evaluateModel(Evaluation.java:1473)"
  </code></pre>
  
  <p>"pred = evl.evaluateModel(classifier,data,{''});" is the exact line that is being pointed to by the error message.</p>
  
  <p>I tried everything, re-installed WEKA, Java as well.But to no use.</p>
  
  <p>any suggestions on getting past this error?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>The error got rectified after upgrading to WEKA 3-7, an error/bug with the library file in WEKA 3-6 I'm guessing.</p>