먼저 라이브러리를 불러오자
import matplotlib.pyplot as plt
import seaborn as sns
이전 글에 이어서 iris 데이터셋을 학습한다.
iris 데이터셋을 train이라는 어레이에 저장해 둔상태다.
train_y = train['variety']
train_x = train.drop(['variety'], axis=1)
plt.figure(figsize = (15,15))
sns.pairplot(train_x)
plt.show()
그렇가면 각 변수별 갯수는 어떻게 될까?
이건 아래의 코드를 실행해보
fig, axes = plt.subplots(2, 2, figsize=(20,20)) #사이즈에 맞게 변경
#index명 입력 추가로 늘려주면서 위치 지정해줘야해
sns.countplot(x = train_x['sepal.length'], ax=axes[0][0]).set_title('sepal.length')
sns.countplot(x = train_x['sepal.width'], ax=axes[0][1]).set_title('sepal.width')
sns.countplot(x = train_x['petal.length'], ax=axes[1][0]).set_title('petal.length')
sns.countplot(x = train_x['petal.width'], ax=axes[1][1]).set_title('petal.width')
plt.show()
'컴퓨터 마스터되기' 카테고리의 다른 글
라벨 인코더 label encoder (0) | 2024.05.08 |
---|---|
[pandas] 데이터 정리 방 (0) | 2024.05.08 |
padas 데이터 구조 확인 방법 (0) | 2024.05.08 |
머신러닝 주로쓰는 라이브러리 정리 (0) | 2024.05.08 |
mariadb 데이터 베이스 오류 (error 2002 (hy000): can't connect to local mysql server through socket '/var/run/mysqld/mysqld.sock' (111 "connection refused")) (0) | 2021.03.25 |