欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

随机森林 extra-trees

程序员文章站 2022-07-14 14:38:58
...

随机森林 extra-trees

import numpy as np
from sklearn.pipeline import Pipeline
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import PolynomialFeatures
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import mean_squared_error
from sklearn.linear_model import LogisticRegression
from sklearn import datasets
from sklearn.svm import SVC
from sklearn.ensemble import VotingClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import BaggingClassifier,RandomForestClassifier,ExtraTreesClassifier


X,y=datasets.make_moons(n_samples=500,noise=0.3,random_state=666)


# train_X,test_X,train_y,test_y = train_test_split(X,y,test_size=0.2,random_state=666)

rf_clf=ExtraTreesClassifier(n_estimators=500,bootstrap=True,random_state=666,oob_score=True,n_jobs=-1)

rf_clf.fit(X,y)
print(rf_clf.oob_score_)
# print(dt_reg.score(train_X, train_y))



随机森林 extra-trees

相关标签: 机器学习