Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,12 +7,12 @@ from sklearn.metrics import mean_squared_error, r2_score
|
|
7 |
import altair as alt
|
8 |
import time
|
9 |
import zipfile
|
|
|
10 |
|
11 |
# Page title
|
12 |
st.set_page_config(page_title='ML Model Building', page_icon='π€', layout='wide') # Set layout to wide for better use of space
|
13 |
st.title('π€ ML Model Building')
|
14 |
|
15 |
-
|
16 |
with st.expander('About this app'):
|
17 |
st.markdown('**What can this app do?**')
|
18 |
st.info('This app allow users to build a machine learning (ML) model in an end-to-end workflow. Particularly, this encompasses data upload, data pre-processing, ML model building and post-model analysis.')
|
@@ -32,7 +32,6 @@ with st.expander('About this app'):
|
|
32 |
- Streamlit for user interface
|
33 |
''', language='markdown')
|
34 |
|
35 |
-
|
36 |
# Sidebar for accepting input parameters
|
37 |
with st.sidebar:
|
38 |
# Load data
|
@@ -130,14 +129,8 @@ if uploaded_file or example_data:
|
|
130 |
st.write("Displaying performance metrics ...")
|
131 |
time.sleep(sleep_time)
|
132 |
parameter_criterion_string = ' '.join([x.capitalize() for x in parameter_criterion.split('_')])
|
133 |
-
#if 'Mse' in parameter_criterion_string:
|
134 |
-
# parameter_criterion_string = parameter_criterion_string.replace('Mse', 'MSE')
|
135 |
rf_results = pd.DataFrame(['Random forest', train_mse, train_r2, test_mse, test_r2]).transpose()
|
136 |
rf_results.columns = ['Method', f'Training {parameter_criterion_string}', 'Training R2', f'Test {parameter_criterion_string}', 'Test R2']
|
137 |
-
# Convert objects to numerics
|
138 |
-
for col in rf_results.columns:
|
139 |
-
rf_results[col] = pd.to_numeric(rf_results[col], errors='ignore')
|
140 |
-
# Round to 3 digits
|
141 |
rf_results = rf_results.round(3)
|
142 |
|
143 |
status.update(label="Status", state="complete", expanded=False)
|
@@ -244,7 +237,6 @@ if uploaded_file or example_data:
|
|
244 |
)
|
245 |
st.altair_chart(scatter, theme='streamlit', use_container_width=True)
|
246 |
|
247 |
-
|
248 |
-
# Ask for CSV upload if none is detected
|
249 |
else:
|
250 |
st.warning('π Upload a CSV file or click *"Load example data"* to get started!')
|
|
|
|
7 |
import altair as alt
|
8 |
import time
|
9 |
import zipfile
|
10 |
+
import os
|
11 |
|
12 |
# Page title
|
13 |
st.set_page_config(page_title='ML Model Building', page_icon='π€', layout='wide') # Set layout to wide for better use of space
|
14 |
st.title('π€ ML Model Building')
|
15 |
|
|
|
16 |
with st.expander('About this app'):
|
17 |
st.markdown('**What can this app do?**')
|
18 |
st.info('This app allow users to build a machine learning (ML) model in an end-to-end workflow. Particularly, this encompasses data upload, data pre-processing, ML model building and post-model analysis.')
|
|
|
32 |
- Streamlit for user interface
|
33 |
''', language='markdown')
|
34 |
|
|
|
35 |
# Sidebar for accepting input parameters
|
36 |
with st.sidebar:
|
37 |
# Load data
|
|
|
129 |
st.write("Displaying performance metrics ...")
|
130 |
time.sleep(sleep_time)
|
131 |
parameter_criterion_string = ' '.join([x.capitalize() for x in parameter_criterion.split('_')])
|
|
|
|
|
132 |
rf_results = pd.DataFrame(['Random forest', train_mse, train_r2, test_mse, test_r2]).transpose()
|
133 |
rf_results.columns = ['Method', f'Training {parameter_criterion_string}', 'Training R2', f'Test {parameter_criterion_string}', 'Test R2']
|
|
|
|
|
|
|
|
|
134 |
rf_results = rf_results.round(3)
|
135 |
|
136 |
status.update(label="Status", state="complete", expanded=False)
|
|
|
237 |
)
|
238 |
st.altair_chart(scatter, theme='streamlit', use_container_width=True)
|
239 |
|
|
|
|
|
240 |
else:
|
241 |
st.warning('π Upload a CSV file or click *"Load example data"* to get started!')
|
242 |
+
|