Main Content

ClassificationBaggedensemble.

Package:classreg.learning.classif.
Superclasses:分类Ensemble

通过重采样种植的分类集合

Description

ClassificationBaggedensemble.combines a set of trained weak learner models and data on which these learners were trained. It can predict ensemble response for new data by aggregating predictions from its weak learners.

建造

使用袋装分类合奏对象使用fitcensemble.。Set the name-value pair argument'方法'fitcensemble.'Bag'使用Bootstrap聚合(袋装,例如随机林)。

特性

BinEdges

Bin edges for numeric predictors, specified as a cell array ofp数字向量,在哪里pis the number of predictors. Each vector includes the bin edges for a numeric predictor. The element in the cell array for a categorical predictor is empty because the software does not bin categorical predictors.

这software bins numeric predictors only if you specify the'numbins'名称 - 值参数作为带有树学习者培训模型时的正整数标量。这BinEdges房产是空的'numbins'value is empty (default).

您可以重现Binned Predictor数据Xbinned通过使用BinEdgesproperty of the trained modelMDL.

x = mdl.x;%predictor数据xbinned = zeros(size(x));边缘= mdl.bineges;%查找箱预测因子的指数。idxnumeric = find(〜cellfun(@ isempty,边));如果是iscumn(idxnumeric)idxnumeric = idxnumeric';j = idxnumeric x = x(:,j);如果x是表,%将x转换为数组。如果是Istable(x)x = table2array(x);结束%X通过使用X进入垃圾箱离散化函数。xbinned =离散化(x,[无穷;边缘{};inf]); Xbinned(:,j) = xbinned; end
Xbinnedcontains the bin indices, ranging from 1 to the number of bins, for numeric predictors.Xbinnedvalues are 0 for categorical predictors. IfXcontainsNaNs,然后相应的Xbinnedvalues areNaNs。

CategoricalPredictors

分类预测索引指定为正整数的向量。CategoricalPredictors包含与包含分类预测器的预测器数据列对应的索引值。如果没有预测器都是分类的,则此属性是空的([]).

ClassNames

List of the elements inY删除了重复项。ClassNamescan be a numeric vector, categorical vector, logical vector, character array, or cell array of character vectors.ClassNames具有the same data type as the data in the argumentY(The software treats string arrays as cell arrays of character vectors.)

CombineWeights

描述如何的字符矢量ens结合弱学习权重,也可以结合'WeightedSum'或者'WeightedAverage'

ExpandedPredictorNames

扩展的预测器名称,存储为字符向量的单元格数组。

If the model uses encoding for categorical variables, thenExpandedPredictorNames包括描述扩展变量的名称。除此以外,ExpandedPredictorNamesis the same asPredictorNames

FitInfo

拟合信息的数字数组。这FitInfoDescriptionproperty describes the content of this array.

FitInfoDescription

描述含义的字符矢量FitInfoarray.

FResample

数字标量01FResampleis the fraction of training datafitcensemble.在构建集合时,随机重新采样。

HyperparameterOptimizationResults

超参数的交叉验证优化的描述,存储为a贝叶斯偏见object or a table of hyperparameters and associated values. Nonempty when the优化hyperParameters.名称 - 值对在创建时是非空的。价值取决于设置的设置HyperParameterOptimizationOptions.name-value pair at creation:

  • 'bayesopt'(default) — Object of class贝叶斯偏见

  • 'gridsearch'或者'randomsearch'- 使用的超参数表,观察到的目标函数值(交叉验证丢失),以及从最低(最佳)到最高(最差)的观察等级

Method

描述创造方法的字符矢量ens

ModelParameters

用于培训的参数ens

麻木

培训的弱学习者数量ens,一个标量。

PredictorNames

Cell array of names for the predictor variables, in the order in which they appear inX

原理

描述原因的字符矢量fitcensemble.stopped adding weak learners to the ensemble.

代替

Logical value indicating if the ensemble was trained with replacement (真的) or without replacement (false).

ResponseName

Character vector with the name of the response variableY

ScoreTransform

用于转换分数的功能手柄,或表示内置变换函数的字符矢量。'none'means no transformation; equivalently,'none'means@(x)x。有关内置转换功能列表和自定义转换功能的语法,请参阅fitctree

添加或更改ScoreTransform功能using dot notation:

ens.ScoreTransform = '功能'

或者

ens.ScoreTransform = @功能

Trained

Trained learners, a cell array of compact classification models.

TrainedWeights

Numeric vector of trained weights for the weak learners inensTrainedWeights具有T元素,在哪里T是弱者的数量learners

Umeryobsforlearner.

逻辑矩阵的大小N-by-麻木, 在哪里Nis the number of observations in the training data and麻木is the number of trained weak learners.Umeryobsforlearner.(I,J)is真的if observationIwas used for training learnerJ, 并且是falseotherwise.

W

Scaled重量, a vector with lengthn, the number of rows inX。元素的总和Wis1

X

Matrix or table of predictor values that trained the ensemble. Each column ofXrepresents one variable, and each row represents one observation.

Y

一个分类阵列,字符向量,字符阵列,逻辑向量的单元阵列,或具有相同行数的数字矢量X。Each row ofY表示相应行的分类X

Object Functions

compact Compact classification ensemble
compareHoldout Compare accuracies of two classification models using new data
crossval 交叉验证合奏
边缘 分类边缘
lime Local interpretable model-agnostic explanations (LIME)
失利 分类error
利润 分类利润s
oObederge. 袋外分类边缘
oobloss. Out-of-bag classification error
oobMargin Out-of-bag classification margins
oobPermutedPredictorImportance Predictor importance estimates by permutation of out-of-bag predictor observations for random forest of classification trees
Oobpredict. 预测集合的袋子响应
partialDependence 计算部分依赖
plotPartialDependence Create partial dependence plot (PDP) and individual conditional expectation (ICE) plots
预测 使用分类模型的集体分类观察
预测或者Importance Estimates of predictor importance for classification ensemble of decision trees
removeLearners Remove members of compact classification ensemble
resubEdge 分类边缘by resubstitution
resubLoss 分类error by resubstitution
resubMargin 分类利润s by resubstitution
resubPredict 分类在分类模型的集合中的观察
resume 恢复训练合奏
shapley 福利价值观
testckfold. 通过重复的交叉验证比较两个分类模型的精度

复制语义

价值。要了解值类如何影响复制操作,请参阅Copying Objects

Examples

collapse all

Load the电离层data set.

load电离层

您可以使用所有测量训练100个分类树的装袋组合。

MDL.= fitcensemble(X,Y,'方法','Bag')

fitcensemble.使用默认模板树对象Templatetree()as a weak learner when'方法'is'Bag'。In this example, for reproducibility, specify'可重复',真实创建树模板对象时,然后将对象用作弱的学习者。

rng('default')% For reproducibilityt = templateTree('可重复',真的);% For reproducibiliy of random predictor selectionsMDL.= fitcensemble(X,Y,'方法','Bag','Learners',t)
MDL.= ClassificationBaggedEnsemble ResponseName: 'Y' CategoricalPredictors: [] ClassNames: {'b' 'g'} ScoreTransform: 'none' NumObservations: 351 NumTrained: 100 Method: 'Bag' LearnerNames: {'Tree'} ReasonForTermination: 'Terminated normally after completing the requested number of training cycles.' FitInfo: [] FitInfoDescription: 'None' FResample: 1 Replace: 1 UseObsForLearner: [351x100 logical] Properties, Methods

MDL.是A.ClassificationBaggedensemble.模型对象。

MDL.。Trainedis the property that stores a 100-by-1 cell vector of the trained classification trees (CompactClassificationTree.model objects) that compose the ensemble.

Plot a graph of the first trained classification tree.

看法(Mdl.Trained{1},'Mode','图形')

Figure Classification Tree Viewer包含UIMEnu,UIControl类型的轴和其他对象。轴包含60个类型的类型线,文本。

By default,fitcensemble.grows deep decision trees for bagged ensembles.

Estimate the in-sample misclassification rate.

L = resubLoss(Mdl)
l = 0.

L是0,表明这一点MDL.is perfect at classifying the training data.

Tips

对于一个袋装的分类树系列,Trainedproperty ofensstores a cell vector ofens.NumTrainedCompactClassificationTree.模型对象。用于树的文本或图形显示tin the cell vector, enter

看法(ens.Trained{t})

扩展能力

Introduced in R2011a