什么是TreeBagger方法中使用的'cat'param

时间:2013-03-16 14:41:08

标签: matlab

我正在关注本教程,并尝试实现TreeBagger方法。我有一个问题,因为我无法理解部分代码。

b = TreeBagger(nTrees,X,Y,'oobpred','on','cat',6,'minleaf',leaf(ii));

谁能告诉我什么' cat'请问和6号?

2 个答案:

答案 0 :(得分:1)

TreeBagger的构造函数:

%   In addition to the optional arguments above, this method accepts all
%   optional CLASSREGTREE arguments with the exception of 'minparent'.
%   Refer to the documentation for CLASSREGTREE for more detail.

'cat'不是TreeBagger的有效输入对之一,因此它必须是CLASSREGTREE的输入。查看classregtree的输入对,接近'cat'的唯一输入对是'分类',它表示:

%      'categorical' Vector of indices of the columns of X that are to be
%                   treated as unordered categorical variables

如果你看一下statgetargs.m,特别是这一行:

i = strmatch(lower(pname),pnames);

只要第一部分拼写正确,它就会允许任何参数。 pnames将包含一个有效字符串的单元格数组(其中一个将是'分类'),而pname将包含一个字符串来比较pnames(最终,它将包含'cat')。如果只输入输入字符串的第一部分,它仍然有效。即对我来说,这是有效的:

EDU>> a = TreeBagger(nTrees,X,Y,'oobpr','on','cat',6,'minle',leaf(ii));
EDU>> b = TreeBagger(nTrees,X,Y,'oobpred','on','cat',6,'minleaf',leaf(ii));
EDU>> isequal(a,b)

ans =

     1

如果'cat'被更改,它不起作用,因为它在TreeArgs下拼写时明确存储'cat'。无论如何,'cat'被视为classregtree的'绝对'。

答案 1 :(得分:0)

cat被视为categorical classregtree输入参数的缩写,它指定X中的第六个变量应被视为分类。< / p>

相关问题