■ 주성분 분석(PCA, Principle Component Analysis) 시각화 알고리즘을 사용하는 방법을 보여준다.
▶ 예제 코드 (PY)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import matplotlib.pyplot as pp import numpy as np import sklearn.datasets as datasets import sklearn.decomposition as decomposition mnistBunch = datasets.load_digits(n_class = 6) imageNDArray = mnistBunch.data labelNDArray = mnistBunch.target pcaNDArray = decomposition.TruncatedSVD(n_components = 2).fit_transform(imageNDArray) figure, axesSubplot = pp.subplots() axesSubplot.scatter(pcaNDArray[:, 0], pcaNDArray[:, 1], c = labelNDArray) axesSubplot.set_xticks(()) axesSubplot.set_yticks(()) pp.show() |