MATLAB:使用 fitctree 训练分类器对新数据进行标签预测
MATLAB: label prediction on new data using fitctree trained classifier
我在MATLAB 2015b中用fitctree构建了一个简单的分类树。我现在想开始使用它对新数据进行预测(tabletest)。 'Predict' 给我一个错误,我不确定如何对新数据使用 kfoldPredict。
代码:
predict(Mdl10feat,tabletest)
错误:
Undefined function 'predict' for input arguments of type
'classreg.learning.partition.ClassificationPartitionedModel'.
分类器:
Mdl10feat =
classreg.learning.partition.ClassificationPartitionedModel
CrossValidatedModel: 'Tree'
PredictorNames: {'fermin' 'MAJ' 'SOL' 'ECC' 'ORI' 'W' 'H' 'CIRC1' 'EQU' 'CONT'}
ResponseName: 'classROI'
NumObservations: 376810
KFold: 10
Partition: [1x1 cvpartition]
ClassNames: {'Hit' 'Miss'}
ScoreTransform: 'none'
输入:
tabletest =
fermin MAJ SOL ECC ORI W H CIRC1 EQU CONT
______ ______ _______ _______ ______ ______ ______ ______ ______ ____
29.748 46.342 0.98621 0.76677 87.506 27.307 43.691 1.0426 36.847 149
我做错了什么?
fitctree
, specifically for the output argument tree
的文档说明如下:
Classification tree, returned as a classification tree object.
Using the 'CrossVal'
, 'KFold'
, 'Holdout'
, 'Leaveout'
, or 'CVPartition'
options results in a tree of class ClassificationPartitionedModel
. You cannot use a partitioned tree for prediction, so this kind of tree does not have a predict
method. Instead, use kfoldPredict
to predict responses for observations not used for training.
Otherwise, tree
is of class ClassificationTree
, and you can use the predict
method to make predictions.
因为您的输出是 ClassificationPartitionedModel
, you therefore have to use the kfoldPredict
方法类型。
请注意我在上面加粗的声明:分区树不能用于对新数据的预测。这是因为给 fitctree
的数据集用于 训练和 testing/validation。从上面的模型输出中,它表明您使用的 'KFold'
值为 10。这意味着您的数据首先被分成 10 组,然后每组用作在另一组上训练的模型的验证集9.kfoldPredict
方法给你分类的结果
如果你想使用所有的数据来训练模型,那么在新数据上使用predict
,你必须避免使用'CrossVal'
、'KFold'
、[=调用 fitctree
.
时的 14=]、'Leaveout'
或 'CVPartition'
选项
我在MATLAB 2015b中用fitctree构建了一个简单的分类树。我现在想开始使用它对新数据进行预测(tabletest)。 'Predict' 给我一个错误,我不确定如何对新数据使用 kfoldPredict。
代码:
predict(Mdl10feat,tabletest)
错误:
Undefined function 'predict' for input arguments of type
'classreg.learning.partition.ClassificationPartitionedModel'.
分类器:
Mdl10feat =
classreg.learning.partition.ClassificationPartitionedModel
CrossValidatedModel: 'Tree'
PredictorNames: {'fermin' 'MAJ' 'SOL' 'ECC' 'ORI' 'W' 'H' 'CIRC1' 'EQU' 'CONT'}
ResponseName: 'classROI'
NumObservations: 376810
KFold: 10
Partition: [1x1 cvpartition]
ClassNames: {'Hit' 'Miss'}
ScoreTransform: 'none'
输入:
tabletest =
fermin MAJ SOL ECC ORI W H CIRC1 EQU CONT
______ ______ _______ _______ ______ ______ ______ ______ ______ ____
29.748 46.342 0.98621 0.76677 87.506 27.307 43.691 1.0426 36.847 149
我做错了什么?
fitctree
, specifically for the output argument tree
的文档说明如下:
Classification tree, returned as a classification tree object.
Using the
'CrossVal'
,'KFold'
,'Holdout'
,'Leaveout'
, or'CVPartition'
options results in a tree of classClassificationPartitionedModel
. You cannot use a partitioned tree for prediction, so this kind of tree does not have apredict
method. Instead, usekfoldPredict
to predict responses for observations not used for training.Otherwise,
tree
is of classClassificationTree
, and you can use thepredict
method to make predictions.
因为您的输出是 ClassificationPartitionedModel
, you therefore have to use the kfoldPredict
方法类型。
请注意我在上面加粗的声明:分区树不能用于对新数据的预测。这是因为给 fitctree
的数据集用于 训练和 testing/validation。从上面的模型输出中,它表明您使用的 'KFold'
值为 10。这意味着您的数据首先被分成 10 组,然后每组用作在另一组上训练的模型的验证集9.kfoldPredict
方法给你分类的结果
如果你想使用所有的数据来训练模型,那么在新数据上使用predict
,你必须避免使用'CrossVal'
、'KFold'
、[=调用 fitctree
.
'Leaveout'
或 'CVPartition'
选项