Spaces:
Runtime error
Runtime error
Isabel Gwara
commited on
Commit
·
4b388b8
1
Parent(s):
376152d
Update app.py
Browse files
app.py
CHANGED
@@ -16,6 +16,8 @@ from os.path import exists
|
|
16 |
### ----------------------------- ###
|
17 |
### interface setup ###
|
18 |
### ----------------------------- ###
|
|
|
|
|
19 |
|
20 |
with open('styles.css') as f:
|
21 |
st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
|
@@ -96,8 +98,10 @@ def train_model():
|
|
96 |
# save the model to file
|
97 |
with open('model.pkl', 'wb') as f:
|
98 |
pkl.dump(model, f)
|
99 |
-
|
100 |
-
|
|
|
|
|
101 |
|
102 |
### -------------------------------- ###
|
103 |
### rerun logic ###
|
@@ -107,7 +111,7 @@ try:
|
|
107 |
with open('model.pkl', 'rb') as f:
|
108 |
model = pkl.load(f)
|
109 |
except FileNotFoundError as e:
|
110 |
-
|
111 |
|
112 |
|
113 |
|
|
|
16 |
### ----------------------------- ###
|
17 |
### interface setup ###
|
18 |
### ----------------------------- ###
|
19 |
+
global acc
|
20 |
+
|
21 |
|
22 |
with open('styles.css') as f:
|
23 |
st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
|
|
|
98 |
# save the model to file
|
99 |
with open('model.pkl', 'wb') as f:
|
100 |
pkl.dump(model, f)
|
101 |
+
|
102 |
+
acc = metrics.accuracy_score(y_test, y_pred)
|
103 |
+
|
104 |
+
return model
|
105 |
|
106 |
### -------------------------------- ###
|
107 |
### rerun logic ###
|
|
|
111 |
with open('model.pkl', 'rb') as f:
|
112 |
model = pkl.load(f)
|
113 |
except FileNotFoundError as e:
|
114 |
+
model = train_model()
|
115 |
|
116 |
|
117 |
|