我正在尝试使用MLJ来训练一些使用随机森林分类器的数据。为了做到这一点,我将我的分类变量转换为Multiclass(scitype),并将连续特征转换为Continuous。(我还将目标变量scitype更改为Multiclass)
MLJ.schema(X)

然而,当我构造机器对象时,我得到了以下警告,
mach = machine(forest, X,y)
┌ Warning: The scitype of `X`, in `machine(model, X, ...)` is incompatible
with `model=RandomForestClassifier @695`:
│ scitype(X) = Table{Union{AbstractArray{Continuous,1},
AbstractArray{Multiclass{8},1}, AbstractArray{Multiclass{3},1},
AbstractArray{Multiclass{14},1}, AbstractArray{Multiclass{7},1},
AbstractArray{Multiclass{12},1}}}
│ input_scitype(model) = Table{var"#s45"} where var"#s45"
<:Union{AbstractArray{var"#s13",1} where var"#s13"<:Count,
AbstractArray{var"#s13",1} where var"#s13"<:OrderedFactor,
AbstractArray{var"#s13",1} where var"#s13"<:Continuous}.当我拟合模型时,后面跟着这个TaskFailedExceptionError
trainRows, testRows = partition(eachindex(y),0.7, shuffle = true)
MLJ.fit(mach, rows = trainRows)我只用连续的特性测试了这个模型,它工作得很好。所以分类变量是不正确的(使用scitype Muticlass),但是不能完全弄清楚它是什么。你知道我做错了什么吗?
发布于 2021-02-26 18:42:25
Inputs are tables with ordinal columns. That is, the element scitype
of each column can be `Continuous`, `Count` or `OrderedFactor`.一种可能的解决方案是将表的分类列扩展为单热点编码列,就像在this forum post中一样。
https://stackoverflow.com/questions/66365311
复制相似问题