본문 바로가기
Kaggle Learn

Data Visualization - Scatter Plots

by 가으더 2024. 3. 21.
728x90

https://www.kaggle.com/code/alexisbcook/scatter-plots

 

Scatter Plots

Explore and run machine learning code with Kaggle Notebooks | Using data from Interesting Data to Visualize

www.kaggle.com

Scatter plots

sns.scatterplot(x=insurance_data['bmi'], y=insurance_data['charges'])

sns.scatterplot을 통해 scatter 생성. 인자는 x, y축 설정

 

sns.regplot : 두 관계의 상관도를 확인하기 위해 회귀선 또는 데이터에 가장 적합한 선을 추가. 

sns.regplot(x=insurance_data['bmi'], y=insurance_data['charges'])

 

Color-coded scatter plots

sns.scatterplot(x=insurance_data['bmi'], y=insurance_data['charges'], hue=insurance_data['smoker'])

흡연이 BMI와 보험 비용 사이의 관계에 어떤 영향을 미치는지 이해하기 위해, '흡연자'에 의해 포인트를 색상 코드화하고, 다른 두 열('bmi', '요금')을 축에 표시

sns.lmplot(x="bmi", y="charges", hue="smoker", data=insurance_data)

 흡연자와 비흡연자에 해당하는 두 개의 회귀선을 추가

sns.swarmplot(x=insurance_data['smoker'],
              y=insurance_data['charges'])

 주 축 중 하나에 범주형 변수(예: "스모커")가 표시되도록 산점도의 설계를 조정할 수 있습니다. 우리는 이 그림 유형을 범주형 산점도라고 부르고 sns.warmplot 명령을 사용하여 이 그림을 만듭니다.