티스토리 뷰

본 예제는 Python 언어와 Scikit-learn 라이브러리를 이용하여 iris 데이터를 scatter plot으로 시각화하는 방법을 다루고 있습니다

 

1. 필요한 라이브러리 설치 및 불러오기

!pip install scikit-learn matplotlib

import matplotlib.pyplot as plt
from sklearn.datasets import load_iris

2. 데이터 불러오기

Scikit-learn에서 제공하는 iris 데이터를 불러옵니다.

iris = load_iris()
X, y = iris.data, iris.target

 

3. 데이터 시각화

불러온 iris 데이터를 scatter plot으로 시각화합니다.

plt.scatter(X[:, 0], X[:, 1], c=y, cmap='viridis')
plt.xlabel(iris.feature_names[0])
plt.ylabel(iris.feature_names[1])
plt.show()

 

728x90
반응형
댓글
250x250
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함
공지사항