Sklearn 결정트리학습

1 개요[ | ]

sklearn 결정트리학습

2 예시 1: 붓꽃 분류[ | ]

from sklearn.datasets import load_iris
iris = load_iris()
X = iris.data
y = iris.target

from sklearn import tree
clf = tree.DecisionTreeClassifier(random_state=0, max_depth=2)
clf = clf.fit(X, y)
tree.plot_tree(clf)

import matplotlib.pyplot as plt
plt.show()

3 예시 2: 유방암 판정[ | ]

from sklearn.datasets import load_breast_cancer
breast_cancer = load_breast_cancer()
X = breast_cancer.data
y = breast_cancer.target

from sklearn import tree
clf = tree.DecisionTreeClassifier(max_depth=1)
clf = clf.fit(X, y)
tree.plot_tree(clf)

import matplotlib.pyplot as plt
plt.show()

4 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}