[개인 프로젝트] 데이터 시각화 및 분석
·
Python/데이터 시각화
💻목표 : 이탈 원인 파악해보기 📝원본 데이터 출처 : https://www.kaggle.com/competitions/playground-series-s4e1/overview 1. 우선 고객의 성별 및 연령별 데이터 확인 f, ax = plt.subplots(1, 2, figsize=(19, 8)) # 성별에 따른 파이 차트 gender_counts = train_data['Gender'].value_counts() # 파이 차트 그리기 ax[0].pie(gender_counts, labels=gender_counts.index, autopct='%1.1f%%', startangle=90, colors=['skyblue', 'lightcoral']) ax[0].set_title('연령별 분포') # 연..
Python - plotly Graph Objects & Plotly Express로 바그래프 만들어보기
·
Python/데이터 시각화
plotly에는 Graph Objects & Plotly Express가 있음 Graph Objects로 바그래프 만들어보기 import plotly.graph_objects as go # 데이터 불러오기 y = [3, 10, 6] #fig = go.Figure() 함수로 기본 그래프 생성 fig = go.figure( # 데이터 입력 data = [go.Bar(y=y)] ) fig.show() Plotly Express로 바그래프 만들어보기 import plotly.express as px y = [3, 10, 6] # px.bar() 함수를 활용해서 bar chart 생성과 동시에 Data, Layout 값 입력 fig = px.bar(y=y) fig.show()
Python - [시각화] regplot, histplot, boxplot, swarmplot, countplot
·
Python/데이터 시각화
1. regplot : 회귀 그래프fit_reg = True : 회귀선 표시 fit_reg = False : 회귀선 표시 x   fig, ax=plt.subplots(1, 2, figsize=(15, 5))sns.regplot(x="total_bill", y="tip", data=tips, ax=ax[0], fit_reg=True)ax[0].set_title('with linear regression line')sns.regplot(x="total_bill", y="tip", data=tips, ax=ax[1], fit_reg=False)ax[1].set_title('without linear regression line')plt.show() 2. histplot : 히스토그램* 막대그래프 vs 히스토그..
Python - [시각화] scatterplot & 다중차트 그리기 & 그래프 이미지 저장
·
Python/데이터 시각화
sns.scatterplot(x = 'x축 칼럼', y= 'y축 칼럼' , hue = '기준', ax = , data = 기준데이터 ) plt.savefig(저장경로/파일이름) : 그래프 이미지 저장 import matplotlib.pyplot as plt import seaborn as sns import pandas as pd import numpy as np tips = sns.load_dataset('tips') fig, ax = plt.subplots() ax.plot([1, 2, 3, 4, 5, 6]) # matplotlib 시각화 sns.scatterplot(x = 'total_bill', y= 'tip', hue = 'sex', ax = ax, data = tips) #seaborn 시각화..
Python - [시각화] Maplotlib Pyplot 모듈 활용 그래프 그리기 (plot / bar)
·
Python/데이터 시각화
fig, ax = plt.subplots(nrows= m, ncols= n, figsize=(6, 3)) fig = 데이터가 담기는 프레임 (액자 같은 것) ax = 데이터가 그려지는 캔버스 m개의 행과 n열로 이루어지고, 규격 사이즈가 6, 3인 그래프 (괄호 부분은 생략 가능함) ax.plot() : 선 그래프 ax.bar() : 막대 그래프 ax.legend(loc = '범례 위치') : 범례 선 그래프 그리기 import matplotlib.pyplot as plt data1 = [10, 14, 19, 20, 25] fig, ax = plt.subplots() ax.plot(data1) plt.show() x축이 두개 이상인 그래프 import matplotlib.pyplot as plt date..