如何在R中使用卡方分割数据(我的属性为6631) 权重

如何在R中使用卡方分割数据(我的属性为6631) 权重,r,statistics,feature-selection,R,Statistics,Feature Selection,当您使用以下方法对数据进行子集时: weights<-chi.squared(Class~.,traindata[1000:2000]) Error in eval(expr, envir, enclos) : object 'Class' not found 看起来,Class列必须位于traindata的前1000列中。因此,您对chi.squared()的调用正在抱怨缺少该列。您只需要确保在通过的每个子集中都包含Classchi.squared()。例如: traindata[1

当您使用以下方法对数据进行子集时:

weights<-chi.squared(Class~.,traindata[1000:2000])

Error in eval(expr, envir, enclos) : object 'Class' not found
看起来,
Class
列必须位于
traindata
的前1000列中。因此,您对
chi.squared()
的调用正在抱怨缺少该列。您只需要确保在通过的每个子集中都包含
Class
chi.squared()
。例如:

traindata[1000:2000]

class\u col它可以工作,但是在分割数据之后,当我在数据中预测时,它就不工作了。尝试使用rm()删除不再需要的对象和/或在较小的数据子集上执行任何操作。如果这不起作用,您可能没有足够的内存来完成此任务。
weights<-chi.squared(Class~.,traindata[1000:2000])

Error in eval(expr, envir, enclos) : object 'Class' not found
traindata[1000:2000]
class_col <- which(names(traindata) == 'Class')
weights <- chi.squared(Class ~ . , traindata[union(class_col, 1000:2000)])