Error: Function 'subsindex' is not defined for values of class 'TreeBagger'
Error: Function 'subsindex' is not defined for values of class 'TreeBagger'
我已经通过 TreeBagger
:
为二元分类训练了一个随机森林
Mdl = TreeBagger(trees, X1, y1, 'NumPredictorsToSample', features, ...
'OOBPrediction', 'on', 'Method', 'classification', 'OOBVarImp', 'on');
我正在尝试 return 训练集的 error (misclassification probability) (X1
):
train_error = error(Mdl, X1, y1)
但是,我收到此错误消息:
Function 'subsindex' is not defined for values of class 'TreeBagger'.
请注意,我不是在寻找袋外错误;我已经顺利拿到了
我敢打赌,您将真实世界的货币命名为变量 error
,并且 MATLAB 正在尝试使用 Mdl
对该变量进行索引。但是,Mdl
不能用作索引,因为它没有定义 subsindex
method,如错误消息所述。输入以下内容,然后重试您的代码:
clear error
您通常不应为变量指定与现有函数相同的名称(即 "shadowing")。 function precedence order 文档是这样说的:
If you create a variable with the same name as a function, MATLAB cannot run that function until you clear the variable from memory.
我已经通过 TreeBagger
:
Mdl = TreeBagger(trees, X1, y1, 'NumPredictorsToSample', features, ...
'OOBPrediction', 'on', 'Method', 'classification', 'OOBVarImp', 'on');
我正在尝试 return 训练集的 error (misclassification probability) (X1
):
train_error = error(Mdl, X1, y1)
但是,我收到此错误消息:
Function 'subsindex' is not defined for values of class 'TreeBagger'.
请注意,我不是在寻找袋外错误;我已经顺利拿到了
我敢打赌,您将真实世界的货币命名为变量 error
,并且 MATLAB 正在尝试使用 Mdl
对该变量进行索引。但是,Mdl
不能用作索引,因为它没有定义 subsindex
method,如错误消息所述。输入以下内容,然后重试您的代码:
clear error
您通常不应为变量指定与现有函数相同的名称(即 "shadowing")。 function precedence order 文档是这样说的:
If you create a variable with the same name as a function, MATLAB cannot run that function until you clear the variable from memory.