728x90
NMF¶
In [1]:
from sklearn.decomposition import NMF
from sklearn.datasets import load_iris
import matplotlib.pyplot as plt
%matplotlib inline
- iris
In [2]:
iris = load_iris()
iris_ftrs = iris.data
- NMF 변환
In [12]:
nmf = NMF(n_components=2, max_iter=1000)
nmf.fit(iris_ftrs)
iris_nmf = nmf.transform(iris_ftrs)
- NMF 변환된 입력 데이터 값 시각화
In [13]:
plt.scatter(x=iris_nmf[:,0], y= iris_nmf[:,1], c= iris.target)
plt.xlabel('NMF Component 1')
plt.ylabel('NMF Component 2')
Out[13]:
Text(0, 0.5, 'NMF Component 2')
728x90
'Data Analytics with python > [Machine Learning ]' 카테고리의 다른 글
[Clustering] MeanShift (0) | 2023.02.14 |
---|---|
[Clustering] K-means (0) | 2023.02.14 |
[Dimension Reduction] SVD 변환 (0) | 2023.02.13 |
[Dimension Reduction] LDA 변환 (0) | 2023.02.13 |
[Dimension Reduction] PCA components 기반 변환 (0) | 2023.02.13 |
댓글