반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- bccard
- 재귀함수
- CES 2O21 참가
- 데이터전문기관
- CES 2O21 참여
- web 개발
- 결합전문기관
- C언어
- 자료구조
- inorder
- KNeighborsClassifier
- mglearn
- discrete_scatter
- postorder
- cudnn
- java역사
- web 용어
- web 사진
- classification
- web
- pycharm
- vscode
- html
- paragraph
- 머신러닝
- 대이터
- Keras
- broscoding
- tensorflow
- 웹 용어
Archives
- Today
- Total
bro's coding
sklearn.ensemble.RandomForestClassifier.basic 본문
반응형
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_train,y_test=train_test_split(cancer.data,cancer.target)
from sklearn.ensemble import RandomForestClassifier
model=RandomForestClassifier(n_estimators=100)
model.fit(X_train,y_train)
train_score=model.score(X_train,y_train)
test_score=model.score(X_test,y_test)
display(train_score,test_score)
# 1.0
# 0.916083916083916
trees=model.estimators_
display(trees)
'''
[DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
max_features='auto', max_leaf_nodes=None,
min_impurity_decrease=0.0, min_impurity_split=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, presort=False,
random_state=132230704, splitter='best'),
DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
max_features='auto', max_leaf_nodes=None,
min_impurity_decrease=0.0, min_impurity_split=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, presort=False,
random_state=1424136292, splitter='best'),
.
.
.
.
'''
model
'''
RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
max_depth=None, max_features='auto', max_leaf_nodes=None,
min_impurity_decrease=0.0, min_impurity_split=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_estimators=100, n_jobs=1,
oob_score=False, random_state=None, verbose=0,
warm_start=False)
'''
result=np.zeros([143,100])
for i in range(100):
result[:,i]=trees[i].predict(X_test)
result
'''
array([[0., 1., 1., ..., 0., 1., 1.],
[1., 1., 1., ..., 1., 1., 1.],
[0., 0., 0., ..., 0., 0., 0.],
...,
[0., 0., 0., ..., 0., 0., 0.],
[1., 1., 1., ..., 1., 1., 1.],
[0., 0., 0., ..., 0., 1., 0.]])
'''
반응형
'[AI] > python.sklearn' 카테고리의 다른 글
sklearn.cluster.KMeans.basic (0) | 2020.04.21 |
---|---|
sklearn.preprocessing.MinMaxScaler, StandardScaler, Normalizer (0) | 2020.04.20 |
sklearn.RandomForestClassifier.feature_importances_(중요도 표현) (0) | 2020.04.20 |
sklearn.ensemble.RandomForestClassifier.2 feature for visualization (0) | 2020.04.20 |
sklearn.install graphviz (0) | 2020.04.20 |
sklearn.tree.DecisionTreeClassifier.max_depth 변화 관찰 (0) | 2020.04.20 |
sklearn.non-linear regression(비선형회귀) (0) | 2020.04.19 |
sklearn.linear_model.Ridge.alpha에 따른 회귀선 변화 관찰 (0) | 2020.04.19 |
Comments