2013-04-06 23 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); 
    }