0

用于提供weka.core.Instances对象的数据库中的文本是否需要符合某种格式?当我尝试使用weka.core.Instances仅包含未格式化文本(通过数据库从数据库提供weka.experiment.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)
4

1 回答 1

0

你确定这个数字属性不应该是类属性吗?你的例外在谷歌搜索中给出了第一个命中。你能给出以下代码的输出吗?

    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);
    }
于 2013-04-06T17:19:03.243 回答