-
Notifications
You must be signed in to change notification settings - Fork 0
/
streamlit-automl.py
93 lines (64 loc) · 2.83 KB
/
streamlit-automl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Angelo Salton <[email protected]>
import pandas as pd
import pickle
from pycaret import anomaly, arules, regression, classification, clustering, nlp
import streamlit as st
# get dataset options (pycaret examples)
# pc_dfs = pd.read_html('https://pycaret.org/get-data/', header=0)[0]
# pickle.dump(pc_dfs, open('assets/pycaret_datasets.pkl', 'wb'))
pc_dfs = pickle.load(open('assets/pycaret_datasets.pkl', 'rb'))
st.title('PyCaret Explorer')
st.write('Hello!')
opt_task = pc_dfs['Default Task'].unique().tolist()
optsel_task = st.sidebar.selectbox('Select a task:', opt_task)
opt_dataset = pc_dfs['Dataset'][pc_dfs['Default Task']==optsel_task].unique().tolist()
optsel_dataset = st.sidebar.selectbox('Select a dataset:', opt_dataset)
if st.sidebar.button('Run'):
# Download data
df = pd.read_csv(f'https://raw.githubusercontent.com/pycaret/pycaret/master/datasets/{optsel_dataset}.csv')
df = df.copy().sample(200)
# Get target
df_target = pc_dfs.loc[pc_dfs['Dataset']==optsel_dataset,'Target Variable'].tolist()[0]
# Get task
df_task = pc_dfs.loc[pc_dfs['Dataset']==optsel_dataset,'Default Task'].tolist()[0]
# Describe data
st.write(f'This dataset has {df.shape[0]} samples and {df.shape[1]} features. Target variable is {df_target}.')
st.dataframe(df.head())
if df_task in ['NLP / Regression','Regression']:
# Setup PyCaret
with st.spinner('PyCaret setup is running...'):
pycset = regression.setup(data=df, target=df_target)
# Compare models
st.dataframe(regression.compare_models())
# End
st.success('End of execution!')
if df_task in ['Classification (Binary)','Classification (Multiclass)']:
# Setup PyCaret
with st.spinner('PyCaret setup is running...'):
pycset = classification.setup(data=df, target=df_target)
# Compare models
st.dataframe(classification.compare_models())
# End
st.success('End of execution!')
if df_task in ['NLP']:
# Setup PyCaret
with st.spinner('PyCaret setup is running...'):
pycset = nlp.setup(data=df, target=df_target)
# Compare models
#st.dataframe(classification.compare_models())
# End
st.success('End of execution!')
if df_task in ['Association Rule Mining']:
# Setup PyCaret
with st.spinner('PyCaret setup is running...'):
pycset = arules.setup(data=df, target=df_target)
# Compare models
#st.dataframe(arules.compare_models())
if df_task in ['Anomaly Detection']:
# Setup PyCaret
with st.spinner('PyCaret setup is running...'):
pycset = anomaly.setup(data=df, target=df_target)
# Compare models
#st.dataframe(anomaly.compare_models())
else:
st.error('Method not implemented.')