ํ์ผ์ ์ฌ๋ฌ๊ฐ๋ก ๋ง๋ค์ด์, app8.py ๋ฅผ ์คํ์ํค๊ณ ๊ฐ๊ฐ์ defํจ์๋ฅผ ์ด์ฉํ๋ ๋ฐฉ์์ด๋ค.
app8.py์ ๋ด์ฉ์ด๋ค
# ํ์ผ์ ๋ถ๋ฆฌํด์ ๊ฐ๋ฐํ๋ ๋ฐฉ๋ฒ
import streamlit as st
from app8_home import run_home #๋ค๋ฅธ ํ์ผ์ defํจ์๋ฅผ ๊ฐ์ ธ์์ ์ฐ๋๋ฐฉ๋ฒ
from app8_eda import run_eda
from app8_ml import run_ml
from app8_about import run_about
def main():
st.title('ํ์ผ ๋ถ๋ฆฌ ์ฑ')
menu = ['Home','EDA','ML','About']
choice = st.sidebar.selectbox('๋ฉ๋ด', menu)
if choice == menu[0]:
run_home() #๋ค๋ฅธ ํ์ผ์ defํจ์๋ฅผ ๊ฐ์ ธ์์ ์ฐ๋๋ฐฉ๋ฒ
elif choice == menu[1]:
run_eda()
elif choice == menu[2]:
run_ml()
elif choice == menu[3]:
run_about()
if __name__ == '__main__':
main()
app8_home.py
import streamlit as st
def run_home() :
st.subheader('ํ ํ๋ฉด')
st.text('ํ์ผ ๋ถ๋ฆฌ ์ฑ ์ค์ต')
st.image('./data/image_03.jpg')
app8_eda.py
import streamlit as st
import pandas as pd
def run_eda():
st.subheader('EDA ํ๋ฉด')
# iris.csv ํ์ผ์ ์ฝ์ด์์ ์ฌ๋ฌ ์ปฌ๋ผ๋ค ์ ํ ๊ฐ๋ฅํ ๋ก ํ์ฌ ์ ํํ ์ปฌ๋ผ๋ค๋ง ํ๋ฉด์ ๋ณด์ฌ์ฃผ๊ณ ์๊ด๊ณ์๋ ๋ณด์ฌ์ฃผ๋๋ก ๊ฐ๋ฐ
df = pd.read_csv('./data/iris.csv')
st.dataframe(df)
# ๋ชจ๋ ์์นํ ๋ณ์์ ๋ํ ์๊ด ๊ณ์ ๊ณ์ฐ
numerical_cols = df.select_dtypes(include=['float64', 'int64']).columns
selected_cols = st.multiselect('์ํ๋ ์ปฌ๋ผ์ ์ ํํ์ธ์', numerical_cols)
if selected_cols:
corr_df = df[selected_cols].corr()
st.write("์ ํํ ์ปฌ๋ผ๋ค ๊ฐ์ ์๊ด ๊ด๊ณ:")
st.write(corr_df)
else:
st.write("์ปฌ๋ผ์ ์ ํํ์ธ์.")
app8_ml.py
import streamlit as st
def run_ml() :
#์์ธกํ๋ ์์
์ ์ํํ๋ค,
st.subheader('์ด ์ฑ์ ...')
app8_about.py
import streamlit as st
def run_about() :
#์์ธกํ๋ ์์
์ ์ํํ๋ค,
st.subheader('about')