chapter 10-1 EDA
plt.rcParams['figure.dpi'] = 300
sns.distplot(df['lane_count'])
chapter 10-2 비교상관성 분석
sns.heatmap(df.corr(), cmap='viridis')
chapter 10-3 시간 시각화
import datetime
import matplotlib.pyplot as plt
df['date'] = pd.to_datetime(df['base_date'], format = '%Y%m%d')
df1 = df.groupby('date')['target'].mean().reset_index()
df1.head()
df1['month'] = df1['target'].rolling(window = 30).mean()
ax = df1.plot(x = 'date', y = 'target', linewidth = 0.5)
df1.plot(x = 'date', y = 'month', color = '#FF7F50', linewidth = 1, ax = ax)
chapter 10-4 분포시각화
df2 = df[['lane_count','maximum_speed_limit']]
df2=df2[df.maximum_speed_limit>= 50]
df2 = df2.groupby('lane_count').count().reset_index()
df2.head(10)
df1 = df[df['lane_count'].isin([1,2,3,4,5])]
df1 = df1[['lane_count','base_hour', 'maximum_speed_limit','target','start_latitude']]
df1 = df1.groupby('lane_count').mean()
df1.head()
chapter 10-5 관계시각화
fig = plt.figure(figsize=(8,8))
fig.set_facecolor('white')
plt.pcolor(df1.values)
# x축 컬럼 설정
plt.xticks(range(len(df1.columns)),df1.columns)
# y축 컬럼 설정
plt.yticks(range(len(df1.index)), df1.index)
# x축 레이블 설정
plt.xlabel('Value', fontsize=14)
# y축 레이블 설정
plt.ylabel('Team', fontsize=14)
plt.colorbar()
plt.show()
chapter 10-6 관계시각화
plt.scatter(df['start_longitude'], df['start_latitude'], s = 50, alpha = 0.4)
plt.show()
chapter 10-7 공간 시각화
import folium
from folium.plugins import MarkerCluster
# folium 지도 생성
m = folium.Map(location=[33.34, 126.5], zoom_start=11)
# MarkerCluster 객체 생성
marker_cluster = MarkerCluster().add_to(m)
# 산점도의 점들을 Marker로 추가
for lat, lon in zip(df['start_latitude'][:100], df['start_longitude'][:100]):
folium.Marker(
location=[lat, lon],
icon=None, # 아이콘 없음
).add_to(marker_cluster) # MarkerCluster에 추가
# folium 지도 출력
chapter 10-8 박스 플롯
plt.figure(figsize = (6, 4))
sns.boxplot(y = 'target', data = df)
plt.show()
https://colab.research.google.com/drive/1dCgplFhswgzZfZnbLm1XKOPgXD0gYp5m?usp=sharing
'KHUDA' 카테고리의 다른 글
KHUDA Data business 02 심화발제 (0) | 2024.03.20 |
---|---|
KHUDA Data buisenss 02 (0) | 2024.03.20 |
KHUDA Data buisness 01 (0) | 2024.03.13 |
KHUDA ML 세션 5주차 (1) | 2024.02.27 |
KHUDA ML 세션 4주차 (1) | 2024.02.20 |