[부스트캠프 AI Tech 5기] Interactive Visualization

박상우·2023년 3월 27일
0

부스트캠프

목록 보기
27/54
post-thumbnail

동적 시각화

정적 시각화

  • feature 별로 Plotting 한다면 공간적 낭비가 큼
  • 각각의 사용자가 원하는 인사이트가 다를 수 있음

동적 시각화 라이브러리

  • Plotly
  • Bokeh
  • Altair

Matplotlib

  • Interactive 제공
  • 다만 웹에 Deploy가 어려움

Plotly

  • SOTA
  • 예시 문서화 잘 되어 있음
  • 통계 시각화, 지리 시각화, 3D 시각화 등 다양한 시각화

Plotly Express

  • Seaborn과 유사하게 만들어 쉬운 문법
  • 커스텀 부분이 부족하지만, 다양한 함수 제공

Bokeh

  • 문법은 Matplotlib과 유사
  • Plotly에 비해 깔끔
  • 비교적 부족한 문서화

Altair

  • Vega 라이브러리를 사용하여 만든 Interactive
  • Pythonic 하지 않은 문법
  • 데이터 크기 5000개 제한

실습

  • Plotly Express
import plotly 
import plotly.express as px 
import seaborn as sns 

Scatter

fig = px.scatter(iris,
				 x = 'sepal_length',
                 y = 'petal_length,
                 size = 'sepal_length',
                 color = 'species',
                 range_x=[4,8],
                 range_y=[0,6],
                 marginal_y='violin',
                 marginal_x='box',
                 trendline='ols',
                 facet_col='species')
                 
fig.show()

Line

fig = px.scatter(flights,
				 x = 'year',
                 y= 'passengers')
                 
fig.show()

Bar

fig = px.bar(medals,
				 x = 'nation',
                 y= 'count',
                 color='medal')
                 
fig.show()
fig = px.bar(medals,
				 x = 'nation',
                 y= 'count',
                 color='medal',
                 barmode='group')
                 
fig.show()

Part-of-Whole

fig = px.treemap(df,
		   		 path = ['day','time','sex'],
           		 values='total_bill')

3D

fig = px.scatter_3d(iris,
					x = 'sepal_length',
                    y = 'sepal_width',
                    z = 'petal_width',
                    color='species)
fig.show()                    

Multidimensional

fig = px.parallel_coordinates(iris,
							  color= "species_id)
fig.show()                    
fig = px.parallel_categories(tips,
							 color="sex")
fig.show()                    

Geo

fig = px.scatter_geo(geo,
					 locations='iso_alpha',
                     color='continent',
                     size="pop",
                     animation_frame="year",
                     projection="natural earth")
fig.show()                    
fig = px.choropleth(geo,
					 locations='iso_alpha',
                     color='continent',
                     projection="natural earth")
fig.show()                    
profile
세상아 덤벼라

0개의 댓글