前面我们了解了决策树和adaboost的决策树墩的原理和实现,在adaboost我们看到,用简单的决策树墩的效果也很不错,但是对于更多特征的样本来说,可能需要很多数量的决策树墩

或许我们可以考虑使用更加高级的弱分类器,下面我们看下CART(Classification And Regression Tree)的原理和实现吧

CART也是决策树的一种,不过是满二叉树,CART可以是强分类器,就跟决策树一样,但是我们可以指定CART的深度,使之成为比较弱的分类器

CART生成的过程和决策树类似,也是采用递归划分的,不过也存在很多的不同之处

数据集:第一列为样本名称,最后一列为类别,中间为特征

复制代码
human    constant    hair    true    false    false    false    true    false    mammal
python    cold_blood    scale    false    true    false    false    false    true    reptile
salmon    cold_blood    scale    false    true    false    true    false    false    fish
whale    constant    hair    true    false    false    true    false    false    mammal
frog    cold_blood    none    false    true    false    sometime    true    true    amphibious
lizard    cold_blood    scale    false    true    false    false    true    false    reptile
bat    constant    hair    true    false    true    false    true    false    mammal
cat    constant    skin    true    false    false    false    true    false    mammal
shark    cold_blood    scale    true    false    false    true    false    false    fish
turtle    cold_blood    scale    false    true    false    sometime    true    false    reptile
pig    constant    bristle    true    false    false    false    true    true    mammal
eel    cold_blood    scale    false    true    false    true    false    false    fish
salamander    cold_blood    none    false    true    false    sometime    true    true    amphibious