【问题标题】:MATLAB: label prediction on new data using fitctree trained classifierMATLAB:使用 fitctree 训练的分类器对新数据进行标签预测
【发布时间】:2018-07-27 13:48:56
【问题描述】:

我在 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 

我在这里做错了什么?

【问题讨论】:

    标签: matlab label classification decision-tree predict


    【解决方案1】:

    fitctree 的文档,特别是 output argument tree,说明如下:

    分类树,作为分类树对象返回。

    使用'CrossVal''KFold''Holdout''Leaveout''CVPartition' 选项会生成ClassificationPartitionedModel 类树。 您不能使用分区树进行预测,因此这种树没有predict 方法。相反,请使用 kfoldPredict 来预测未用于训练的观察的响应。

    否则tree属于ClassificationTree类,你可以使用predict方法进行预测。

    由于您的输出是ClassificationPartitionedModel 类型,因此您必须使用kfoldPredict 方法。

    请注意我上面加粗的语句:分区树不能用于预测新数据。这是因为提供给fitctree 的数据集用于 训练和测试/验证。从上面的模型输出中可以看出,您使用的 'KFold' 值为 10。这意味着您的数据首先被划分为 10 个集合,然后每个集合都用作在其他 9 个模型上训练的模型的验证集。 kfoldPredict 方法为您提供分类结果。

    如果你想使用所有数据来训练模型,然后在新数据上使用predict,你必须避免使用'CrossVal''KFold''Holdout''Leaveout'或@调用fitctree时的987654350@选项。

    【讨论】:

    • 2015b好像没有kfoldPredict,必须下载2017b。我看到了如何从训练数据中检查标签,但我真的不知道如何使用它来获取新数据的类标签。如何使用 kfoldPredict 获取“tabletest”示例的标签?
    猜你喜欢
    • 2020-12-07
    • 2018-05-28
    • 2014-01-30
    • 2019-05-20
    • 1970-01-01
    • 1970-01-01
    • 2017-05-06
    • 2012-05-31
    • 2018-03-07
    相关资源
    最近更新 更多