集成学习与随机森林
更新权重
Adaboost
-
AdaBoostClassifier(base_estimator=None, n_estimators=50,
learning_rate=1.0, algorithm=’SAMME.R’,
random_state=None)
- base_estimator:可选参数,默认为DecisionTreeClassifier。
- algorithm: 可选参数,默认为SAMME.R
-
循环训练,实例权重不断更新(不是是成本函数最小化,而是加入更多预测器)
Gradient Boosting
xgboost
xgbc = XGBClassifier(max_depth=2,
learning_rate=1,
n_estimators=2, # number of iterations or number of trees
slient=0,
objective="binary:logistic"
)
不更新权重
投票分类器
-
基于多分类器的结果聚合
- voting_clf = VotingClassifier(estimators=[
(‘log_clf’, LogisticRegression()),
(‘svm_clf’, SVC(probability=True)),
(‘dt_clf’, DecisionTreeClassifier(random_state=10)),
], voting=‘soft’)
voting_clf.fit(X_train, y_train)
voting_clf.score(X_test, y_test)
bagging./pasting