【问题标题】:set a numeric attribute values to null with weka使用 weka 将数值属性值设置为 null
【发布时间】:2018-03-19 19:21:01
【问题描述】:

我开发了一个模型来进行回归。 我现在需要给它一个数据集作为输入并接收预测结果作为输出。 我的目标属性是数字,我想我需要在输入数据集中用“null”值填充它。

这是我将目标属性的值设置为 null 的代码:

    //a method to vacate a given column situated in a given index 
private Instances vacateAttribute(Instances dataCSV, int index) {


    Instance instance ;
    //at each iteration, fill the value of the "Nombre" column in the given index  with a null value
            for (int i=0; i < dataCSV.numInstances();i++) {
                //read the value of each row of dataCSV
                instance =  dataCSV.instance(i);
                instance.setValue(index,null );     //attribute("DureeNumeric"). index 7

                }                                       
    return dataCSV;
}  

我收到此异常,告诉我该属性既不是名义上的也不是字符串。

java.lang.IllegalArgumentException: Attribute neither nominal nor string!
at weka.core.AbstractInstance.setValue(AbstractInstance.java:501) ~[weka-stable-3.8.0.jar:na] 

那么我可以将我的数字属性值设置为 null 吗?

提前致谢

【问题讨论】:

    标签: machine-learning regression weka prediction data-cleaning


    【解决方案1】:

    我已经通过将预测结果分配到同一列而不是用 Null 值填充现有列并将预测结果分配到新列中来解决此问题。

    【讨论】:

      猜你喜欢
      • 2010-10-03
      • 2017-10-12
      • 1970-01-01
      • 2018-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-20
      • 1970-01-01
      相关资源
      最近更新 更多