Building Machine Learning System with Python 한국어판
https://github.com/luispedro/BuildingMachineLearningSystemsWithPython
#!/usr/bin/env python
# -*- coding:utf-8 -*-
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
# sklearn의 load_iris로 데이터를 로드한다.
from sklearn.datasets import load_iris
data = load_iris()
# load_iris는 몇 개의 필드를 객체를 반환한다.
features = data.data
features_names = data.feature_names
target = data.target
target_names = data.target_names
# 0:1, 0:2, 0:3
# 1:0, 1:2, 1:3
# 2 .. 3 총 12가지 가짓수 출력이 가능함
def eng_to_kor(eng):
kor = eng.replace("sepal", unicode("꽃받침", "utf-8"))
kor = kor.replace("petal", unicode("꽃잎", "utf-8"))
kor = kor.replace("length", unicode("길이", "utf-8"))
kor = kor.replace("width", unicode("넓이", "utf-8"))
return kor
i = 0
for x in range(4):
for y in range(4):
if x == y: continue
# print "[{0}]\t".format(i), x, y
i += 1
# continue
for t in range(3):
if t == 0:
c = 'r'
marker = '>'
elif t == 1:
c = 'g'
marker = 'o'
elif t == 2:
c = 'b'
marker = 'x'
plt.scatter(features[target == t, x],
features[target == t, y],
marker=marker,
c=c)
plt.rc('font', family='NanumGothicCoding')
_xlabel = eng_to_kor(features_names[x])
_ylabel = eng_to_kor(features_names[y])
_title = "[{0}] ".format(i) + _xlabel + " vs. " + _ylabel
plt.title(_title)
plt.xlabel(_xlabel)
plt.ylabel(_ylabel)
plt.show()
출력된 그림