Bagging Classifier+Regressor


from sklearn.ensemble import BaggingRegressor

Bagging通過引入隨機化增大每個估計器之間的差異。

參數介紹:

    base_estimator:Object or None。None代表默認是DecisionTree,Object可以指定基估計器(base estimator)。

    n_estimators:int, optional (default=10) 。   要集成的基估計器的個數。

    max_samples: int or float, optional (default=1.0)。決定從x_train抽取去訓練基估計器的樣本數量。int 代表抽取數量,float代表抽取比例

    max_features : int or float, optional (default=1.0)。決定從x_train抽取去訓練基估計器的特征數量。int 代表抽取數量,float代表抽取比例

    bootstrap : boolean, optional (default=True) 決定樣本子集的抽樣方式(有放回和不放回)

    bootstrap_features : boolean, optional (default=False)決定特征子集的抽樣方式(有放回和不放回)

    oob_score : bool 決定是否使用包外估計(out of bag estimate)泛化誤差

    warm_start : bool, optional (default=False) true代表

    n_jobs : int, optional (default=1) 

    random_state : int, RandomState instance or None, optional (default=None)。如果int,random_state是隨機數生成器使用的種子; 如果RandomState的實例,random_state是隨機數生成器; 如果None,則隨機數生成器是由np.random使用的RandomState實例。

    verbose : int, optional (default=0) 

屬性介紹:

    estimators_ : list of estimators。The collection of fitted sub-estimators.

    estimators_samples_ : list of arrays

    estimators_features_ : list of arrays

    oob_score_ : float,使用包外估計這個訓練數據集的得分。

    oob_prediction_ : array of shape = [n_samples]。在訓練集上用out-of-bag估計計算的預測。 如果n_estimator很小,則可能在抽樣過程中數據點不會被忽略。 在這種情況下,oob_prediction_可能包含NaN。

還要解決三個問題

①他到底是什么,用於什么情況?

  BaggingRegressor就是一個Bagging的回歸器組合。說到底還是用於集成多個回歸器,所以還是會勇於回歸預測的情況,集成一下解決過擬合的問題。

②他的優缺點?

  

③調參過程?

from sklearn.ensemble import BaggingClassifier


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM