2013-04-06 22 views
0

數據庫中用於提供weka.core.Instances對象的文本是否需要符合某種格式?當我嘗試建立一個weka.core.Instances對象僅包含未格式化的文本(通過weka.experiment.InstanceQuery.query.retrieveInstances()從數據庫喂)作爲其非類屬性我得到下面的異常分類:weka數據庫中的文本格式

Exception in thread "main" 
weka.core.UnsupportedAttributeTypeException: 
    weka.classifiers.functions.SMO: Cannot handle numeric class! at 
    weka.core.Capabilities.test(Unknown Source)  at 
    weka.core.Capabilities.test(Unknown Source)  at 
    weka.core.Capabilities.test(Unknown Source)  at 
    weka.core.Capabilities.testWithFail(Unknown Source)  at 
    weka.classifiers.functions.SMO.buildClassifier(Unknown Source) at 
    Test.main(Test.java:135) 

回答

0

你確定這個數值屬性不應該是類屬性。您的例外情況在Google搜索中顯示爲first hit。你可以給出以下代碼的輸出。

Instances data = null; 

    try { 
     DatabaseUtils utils = new DatabaseUtils(); 

     InstanceQuery query = new InstanceQuery(); 

     query.setUsername(username); 
     query.setPassword(password); 
     query.setQuery(pSql); 

     data = query.retrieveInstances(); 
     data.setRelationName(pInstanceRelationName); 


     if (data.classIndex() == -1) 
     { 
      data.setClassIndex(data.numAttributes() - 1); 
     } 
        // this line will print out your header + data. 
        // add your header information to your question. 
     System.out.println(data) 
    } 

     catch (Exception e) { 
     throw new RuntimeException(e); 
    }