使用 weka 将数字属性值设置为 null

set a numeric attribute values to null with weka

我开发了一个模型来进行回归。 我现在需要给它一个数据集作为输入,并接收预测结果作为输出。 我的目标属性是数字,我想我需要用输入数据集中的 "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 吗?

提前致谢

我遇到过这种情况,方法是将预测结果分配到同一列中,而不是用 Null 值填充现有列并将预测结果分配到新列中。