2015-01-09 100 views
-5

錯誤:在weka.core.Capabilities.testWithFail(Capabilities.java:1302) 在weka.classifiers.trees.j48.C45PruneableClassifierTree.buildClassifier(C45PruneableClassifierTree.java:116) 在weka.classifiers.trees .J48.buildClassifier(J48.java:236) 在Classify.main(Classify.java:45)Weka中的java

basically the run time error is at the line nb1.buildClassifier(train); 







import java.io.BufferedReader; 
    import java.io.FileNotFoundException; 
    import java.io.FileReader; 
    import weka.classifiers.Classifier; 
    import weka.classifiers.Evaluation; 
    import weka.classifiers.evaluation.NominalPrediction; 
    import weka.classifiers.rules.DecisionTable; 
    import weka.classifiers.rules.PART; 
    import weka.classifiers.trees.DecisionStump; 
    import weka.classifiers.trees.J48; 
    import weka.core.FastVector; 
    import weka.core.Instances; 
    import java.io.*; 
    import weka.classifiers.bayes.NaiveBayes; 
    import java.io.BufferedWriter; 
    import weka.core.*; 

public class Classify { 



public static void main(String[] args) throws Exception { 

BufferedReader breader=null; 

Instances train=new Instances(breader); 




train.setClassIndex(train.numAttributes() -1); 



breader=new BufferedReader(new FileReader("C://Users/user/Desktop/test.arff")); 
        Instances test=new Instances (breader); 




        Instances labeled = new Instances(test); 


         double clsLabel=tree.classifyInstance(test.instance(i)); 
         labeled.instance(i).setClassValue(clsLabel); 









       } 
    } 
        ` 

回答

0

在我看來,它不能處理多值標稱類。嘗試更改類屬性的類型或嘗試其他分類器。

+0

但是,當我直接使用Weka運行它時,我確實得到了結果,所以我不認爲這可能是原因 – user3531927

+0

您能否與我們分享training.arff?上傳並分享鏈接,以便我可以檢查它。 –

+0

這裏是arff文件http://axon.cs.byu.edu/~martinez/classes/478/stuff/labhints/tennis.arff – user3531927