Java weka数据库中的文本格式
数据库中用于提供Java weka数据库中的文本格式,java,database,weka,Java,Database,Weka,数据库中用于提供weka.core.Instances对象的文本是否需要符合特定格式?当我尝试使用weka.core.Instances对象构建一个分类器,该对象仅包含未格式化文本(通过weka.experience.InstanceQuery.query.retrieveInstances())作为其非类属性时,我得到以下异常: Exception in thread "main" weka.core.UnsupportedAttributeTypeException: weka.cl
weka.core.Instances
对象的文本是否需要符合特定格式?当我尝试使用weka.core.Instances
对象构建一个分类器,该对象仅包含未格式化文本(通过weka.experience.InstanceQuery.query.retrieveInstances()
)作为其非类属性时,我得到以下异常:
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)
您确定此数值属性不应该是类属性吗。你的例外情况在谷歌搜索中是这样的。你能给出以下代码的输出吗
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);
}