20151115

python scikit-learn 패키지 사용법 확인
– 졸업 논문에 decision tree를 적용하고자 함. 실험 데이터에 기반해 decision tree를 생성해야 하는데, decision tree 학습에 python의 scikit-learn을 사용하고자 한다.
– scikit-learn 프로젝트 홈페이지는 [1]이고, 다양한 예제를 제공하고 있다. 하지만 개인적으로는 scikit-learn 프로젝트 홈페이지에서 제공하는 decision tree 예제[3]를 이해하기 힘들었다. 대신에 Jason Brownlee가 쓴 decision tree 사용 예제[4]를 보고 이해할 수 있었다.

#code by Jason Brownlee
#http://machinelearningmastery.com/a-gentle-introduction-to-scikit-learn-a-python-machine-learning-library/
# Decision Tree Classifier
from sklearn import datasets
from sklearn import metrics
from sklearn.tree import DecisionTreeClassifier

# load the iris datasets
dataset = datasets.load_iris()
# fit a CART model to the data
model = DecisionTreeClassifier()
model.fit(dataset.data, dataset.target)
print(model)
# make predictions
expected = dataset.target
predicted = model.predict(dataset.data)
# summarize the fit of the model
print(metrics.classification_report(expected, predicted))
print(metrics.confusion_matrix(expected, predicted))

References:
[1] scikit-learn, http://scikit-learn.org/stable/index.html
[2] examples, scikit-learn, http://scikit-learn.org/stable/auto_examples/index.html
[3] decision trees, scikit-learn, http://scikit-learn.org/stable/modules/tree.html
[4] Jason Brownlee, A Gentle Introduction to Scikit-Learn: A Python Machine Learning Library, http://machinelearningmastery.com/a-gentle-introduction-to-scikit-learn-a-python-machine-learning-library/

Advertisements
Tagged with: , , , , , , , , , , , ,
Posted in 1) Memo

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

누적 방문자 수
  • 93,229 hits
%d bloggers like this: