集成学习肯定是在实战中最不可或缺的思想了.毕竟都想把错误率低一点,再低一点,再低一点.看看kaggle大量的集成学习就知道这节肯定绕不过去了.
官方文档:[Ensemble methods](http://scikit-learn.org/stable/modules/ensemble.html
bagging的原理介绍可以看:机器学习笔记十三:Ensemble思想(上)
在这里,仅仅说一下最基本的bagging的类,至于更加具体的随机森林或者boosting方法会具体的开一篇来写。bagging有两个类,一个是BaggingClassifier,还有一个是BaggingRegressor,两种形式都是类似的,所以之详细说BaggingClassifier,另外一个类比就行。
class sklearn.ensemble.BaggingClassifier(base_estimator=None,n_estimators=10, max_samples=1.0,max_features=1.0,bootstrap=True,bootstrap_features=False,oob_score=False,warm_start=False, n_jobs=1, random_state=None, verbose=0)
参数:
base_estimator : 一个对象或者None,默认是None,这里是传入一个基本的学习器对象,比如Ridge对象啊,等等。要是None的话,学习器就是决策树。
n_estimators : int类型,表示基本学习器的数量。默认是10
max_samples : int类型或者float类型, 默认为1.0. 这个参数表示从数据集X中抽出多少的数据用来训练基本的学习器。当为整数的时候,就抽出整数个样本,当为浮点数的时候,就抽出该比例的样本。
max_features : int or float, optional (default=1.0)
The number of features to draw from X to train each base estimator.
If int, then draw max_features features.
If float, then draw max_features * X.shape[1] features.
bootstrap : boolean, optional (default=True)
Whether samples are drawn with replacement.
bootstrap_features : boolean, optional (default=False)
Whether features are drawn with replacement.
oob_score : bool
Whether to use out-of-bag samples to estimate the generalization error.
warm_start : bool, o