728x90
https://www.kaggle.com/code/alexisbcook/distributions
Distributions
Explore and run machine learning code with Kaggle Notebooks | Using data from Interesting Data to Visualize
www.kaggle.com
Histograms
# Histogram
sns.histplot(iris_data['Petal Length (cm)'])
Petal Length를 x 축으로 잡고 길이에 따른 count 값을 히스토그램으로 나타낸다.
Density plots
밀도 함수. 쉽게 스무스한 히스토그램이라 생각하면 된다.
# KDE plot
sns.kdeplot(data=iris_data['Petal Length (cm)'], shade=True)
2D KDE plots
한 열의 제한하지 않고 2차원의 밀도 함수를 나타낸다.
# 2D KDE plot
sns.jointplot(x=iris_data['Petal Length (cm)'], y=iris_data['Sepal Width (cm)'], kind="kde")
Petal length와 Sepal width의 조합을 jointplot을 통해 나타낸다.
그림 상단의 곡선은 x축의 데이터에 대한 그래프(iris_data['Petal Length(cm)'])
그림 오른쪽의 곡선은 y축의 데이터에 대한 KDE 그래프(iris_data['Sepal Width(cm)'])
Color-coded plots
종 사이의 차이점을 이해하기 위한 plots을 만들 것이다.
sns.histplot 커맨드를 통해 종에 따른 히스토그램 생성
- hue= : 데이터를 여러 히스토그램으로 분할하는 데 사용할 열을 설정 ex) 종에 따른 분
# Histograms for each species
sns.histplot(data=iris_data, x='Petal Length (cm)', hue='Species')
# Add title
plt.title("Histogram of Petal Lengths, by Species")
KDE plot으로도 만들 수 있다.
# KDE plots for each species
sns.kdeplot(data=iris_data, x='Petal Length (cm)', hue='Species', shade=True)
# Add title
plt.title("Distribution of Petal Lengths, by Species")
'Kaggle Learn' 카테고리의 다른 글
Time Series - Linear Regression With Time Series (1) | 2024.05.21 |
---|---|
Data Visualization - Choosing Plot Types and Custom Styles (0) | 2024.03.23 |
Data Visualization - Scatter Plots (1) | 2024.03.21 |
Data Visualization - Bar Charts and Heatmaps (0) | 2024.03.21 |
Data Visualization - Line Charts (0) | 2024.03.21 |