标签:tst img bubuko 多个 fit 决定 决策 alt 没有
import numpy as np import matplotlib.pyplot as plt from sklearn import datasets from sklearn.model_selection import train_test_split X, y = datasets.make_moons(n_samples=500, noise=0.3, random_state=42) X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42) plt.scatter(X[y==0, 0], X[y==0, 1]) plt.scatter(X[y==1, 0], X[y==1, 1]) plt.show()
from sklearn.tree import DecisionTreeClassifier from sklearn.ensemble import BaggingClassifier bagging_clf = BaggingClassifier(DecisionTreeClassifier(), n_estimators=500, max_samples=200, bootstrap=True) bagging_clf.fit(X_train, y_train) bagging_clf.score(X_test, y_test) # 准确率:0.904
标签:tst img bubuko 多个 fit 决定 决策 alt 没有
原文地址:https://www.cnblogs.com/volcao/p/9486417.html