Java Weka: java.lang.ClassCastException -


i working on simple experiment on weka. trying simple cross-validation , got error. below error message generate output.

java.lang.classcastexception: java.lang.integer cannot cast weka.classifiers.evaluation.output.prediction.abstractoutput @ weka.classifiers.evaluation.evaluatemodel(evaluation.java:1471) @ assg.assg.crossvalidation(assg.java:171) @ assg.assg.main(assg.java:160) 

below coding

public static void crossvalidation() throws exception {     eval.evaluatemodel(cls, training, 10, new random(1));     system.out.println(eval.tosummarystring()); } 

did read error message , docs function you're calling?

  /**    * evaluates classifier on given set of instances. note    * data must have same format (e.g. order of    * attributes) data used train classifier! otherwise    * results meaningless.    *    * @param classifier machine learning classifier    * @param data set of test instances evaluation    * @param forpredictionsprinting varargs parameter that, if supplied,    * expected hold weka.classifiers.evaluation.output.prediction.abstractoutput    * object    * @return predictions    * @throws exception if model not evaluated    *    */   public double[] evaluatemodel(classifier classifier,                                 instances data,                                 object... forpredictionsprinting)  

you're passing primative int (which autoboxed java.lang.integer) argument function expecting weka.classifiers.evaluation.output.prediction.abstractoutput. you're going casting error since types aren't compatible.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -