반응형
Notice
Recent Posts
Recent Comments
Link
관리 메뉴

bro's coding

sklearn.ensemble.RandomForestClassifier.2 feature for visualization 본문

[AI]/python.sklearn

sklearn.ensemble.RandomForestClassifier.2 feature for visualization

givemebro 2020. 4. 20. 15:01
반응형

https://broscoding.tistory.com/160

 

머신러닝.RandomForestClassifier.기초

import numpy as np import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.datasets import load_breast_cancer cancer=load_breast_cancer() X_train,X_test,y_t..

broscoding.tistory.com

 

X=cancer.data[:,[0,1]]
y=cancer.target

X_train,X_test,y_train,y_test=train_test_split(X,y)

model=RandomForestClassifier(n_estimators=100,max_features='auto')
model.fit(X_train,y_train)

import mglearn

plt.figure(figsize=[12,10])
mglearn.plots.plot_2d_classification(model,X)
mglearn.discrete_scatter(X[:,0],X[:,1],y,alpha=0.3)

plt.figure(figsize=[12,10])
for i in range(5):
    plt.subplot(2,3,i+1)
    mglearn.plots.plot_tree_partition(X,y,model.estimators_[i])
    
    plt.subplot(2,3,6)
    mglearn.plots.plot_2d_classification(model,X)
    mglearn.discrete_scatter(X[:,0],X[:,1],y,alpha=0.3)

반응형
Comments