1 분 소요

voila -> 쉽게 프로토타입 만듬 / 대시보드 처럼 레이아웃 잡기는 힘듬

Streamlit

왜 써

웹서비스 만드는 과정

데이터 분석가의 웹서비스 Flow

image-20221109091449474

프론트엔드/PM 조직과의 협업

image-20221109091704941

너무 복잡하고 협업 이후에 모델 업데이트가 불가해진다

-> Streamlit을 사용하자!

Streamlit의 대안)

image-20221109091906315

설치 - pip3 install streamlit

실행방법 - streamlit run < 파일이름>.py

기능

  • st.title, st.header, st.subheader (제목) , st.write(메세지 표시)
  • st.button, st.checkbox (ipy랑 비슷한 요소들이 있음)
  • st.dataframe : interactive 한 dataframe (컬럼 클릭 가능, 정렬 가능)
  • st.table: static 한 dataframe

  • st.metric : 지표 작성
  • st.json
  • st.line_chart

  • st.map

그 외에도 plotly chart등을 쉽게 사용할 수 있음: https://docs.streamlit.io/library/api-reference/charts

  • st.radio, st.selectbox
  • st.slider
  • Input box, caption, code, latex 까즤
  • st.expander : 버튼 눌렀을 때 특정 기능(버튼 눌러서 확장)
  • spinner : 연산 도중 메세지 띄우고 싶을 때
  • ballons : 효과 넣을 때 사용
  • status box : 색깔 다양하게 넣어줄 수 있음
  • form : 로그인 창 같은 입력 Form 만들 수 있음
  • file_uploader

st 공식 문서 확인하면서 ㄱ

https://docs.streamlit.io/library/api-reference

st cheat sheet

https://share.streamlit.io/daniellewisdl/streamlit-cheat-sheet/app.py

data flow

streamlit은 업데이트 되면 전체 코드가 실행된다.

  • 코드 수정된 경우
  • 사용자가 streamli의 위젯과 상호작용 하는 경우

-> 중복 이벤트를 할 수 없다

-> session state를 개발함

st.session_state 로 global variable 생성 느낌으로 사용

Streamlit Cache - @st.cache

캐싱 : 성능을 위해 메모리 등에 저장하는 행위

데이터를 읽는 함수를 만들고, 데코레이터 적용

@st.cache
def load_data():

카테고리:

업데이트:

댓글남기기