Spaces:
Sleeping
Sleeping
Commit
•
9111099
1
Parent(s):
dd5679e
Update app.py
Browse files
app.py
CHANGED
@@ -83,21 +83,42 @@ def POMPredicter(POMFinder, Gr, y_onehotenc_cat):
|
|
83 |
y_pred_proba = y_pred_proba[:,1];
|
84 |
res = sorted(range(len(y_pred_proba)), key = lambda sub: y_pred_proba[sub]);
|
85 |
res.reverse();
|
86 |
-
|
87 |
name = str(y_onehotenc_cat.categories_[0][res[0]])[2:-2]
|
88 |
if name.startswith("icsd"):
|
89 |
st.markdown(f'<span style="font-size: 24px; color: green;">The 1st guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[0]])[2:-2]+"cale.xyz"}</b> with a probability of {100*y_pred_proba[res[0]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
90 |
-
st.markdown(f'<span style="font-size: 24px; color: green;">The 2nd guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[1]])[2:-2]+"cale.xyz"}</b> with a probability of {100*y_pred_proba[res[1]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
91 |
-
st.markdown(f'<span style="font-size: 24px; color: green;">The 3rd guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[2]])[2:-2]+"cale.xyz"}</b> with a probability of {100*y_pred_proba[res[2]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
92 |
-
st.markdown(f'<span style="font-size: 24px; color: green;">The 4th guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[3]])[2:-2]+"cale.xyz"}</b> with a probability of {100*y_pred_proba[res[3]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
93 |
-
st.markdown(f'<span style="font-size: 24px; color: green;">The 5th guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[4]])[2:-2]+"cale.xyz"}</b> with a probability of {100*y_pred_proba[res[4]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
94 |
else:
|
95 |
st.markdown(f'<span style="font-size: 24px; color: green;">The 1st guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[0]])[2:-2]+".xyz"}</b> with a probability of {100*y_pred_proba[res[0]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
96 |
-
st.markdown(f'<span style="font-size: 24px; color: green;">The 2nd guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[1]])[2:-2]+".xyz"}</b> with a probability of {100*y_pred_proba[res[1]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
97 |
-
st.markdown(f'<span style="font-size: 24px; color: green;">The 3rd guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[2]])[2:-2]+".xyz"}</b> with a probability of {100*y_pred_proba[res[2]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
98 |
-
st.markdown(f'<span style="font-size: 24px; color: green;">The 4th guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[3]])[2:-2]+".xyz"}</b> with a probability of {100*y_pred_proba[res[3]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
99 |
-
st.markdown(f'<span style="font-size: 24px; color: green;">The 5th guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[4]])[2:-2]+".xyz"}</b> with a probability of {100*y_pred_proba[res[4]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
return res, y_pred_proba
|
102 |
|
103 |
# Define a download button to download the file
|
@@ -139,7 +160,7 @@ def create_zip_with_txt(y_onehotenc_cat, res, y_pred_proba):
|
|
139 |
# Create and add the txt file with model guesses
|
140 |
with zipf.open("model_guesses.txt", "w") as f:
|
141 |
for i in range(5):
|
142 |
-
name = str(y_onehotenc_cat.categories_[0][res[
|
143 |
if name.startswith("icsd"):
|
144 |
guess_text = f'The {i+1}st guess from the model is: {str(y_onehotenc_cat.categories_[0][res[i]])[2:-2]+"cale.xyz"} with a probability of {y_pred_proba[res[i]]:.2f} %\n'
|
145 |
f.write(guess_text.encode('utf-8'))
|
|
|
83 |
y_pred_proba = y_pred_proba[:,1];
|
84 |
res = sorted(range(len(y_pred_proba)), key = lambda sub: y_pred_proba[sub]);
|
85 |
res.reverse();
|
86 |
+
|
87 |
name = str(y_onehotenc_cat.categories_[0][res[0]])[2:-2]
|
88 |
if name.startswith("icsd"):
|
89 |
st.markdown(f'<span style="font-size: 24px; color: green;">The 1st guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[0]])[2:-2]+"cale.xyz"}</b> with a probability of {100*y_pred_proba[res[0]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
90 |
else:
|
91 |
st.markdown(f'<span style="font-size: 24px; color: green;">The 1st guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[0]])[2:-2]+".xyz"}</b> with a probability of {100*y_pred_proba[res[0]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
92 |
|
93 |
+
name = str(y_onehotenc_cat.categories_[0][res[1]])[2:-2]
|
94 |
+
if name.startswith("icsd"):
|
95 |
+
st.markdown(f'<span style="font-size: 24px; color: green;">The 1st guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[1]])[2:-2]+"cale.xyz"}</b> with a probability of {100*y_pred_proba[res[1]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
96 |
+
else:
|
97 |
+
st.markdown(f'<span style="font-size: 24px; color: green;">The 1st guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[1]])[2:-2]+".xyz"}</b> with a probability of {100*y_pred_proba[res[1]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
98 |
+
|
99 |
+
name = str(y_onehotenc_cat.categories_[0][res[0]])[2:-2]
|
100 |
+
if name.startswith("icsd"):
|
101 |
+
st.markdown(f'<span style="font-size: 24px; color: green;">The 1st guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[2]])[2:-2]+"cale.xyz"}</b> with a probability of {100*y_pred_proba[res[2]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
102 |
+
else:
|
103 |
+
st.markdown(f'<span style="font-size: 24px; color: green;">The 1st guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[2]])[2:-2]+".xyz"}</b> with a probability of {100*y_pred_proba[res[2]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
104 |
+
|
105 |
+
name = str(y_onehotenc_cat.categories_[0][res[0]])[2:-2]
|
106 |
+
if name.startswith("icsd"):
|
107 |
+
st.markdown(f'<span style="font-size: 24px; color: green;">The 1st guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[3]])[2:-2]+"cale.xyz"}</b> with a probability of {100*y_pred_proba[res[3]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
108 |
+
else:
|
109 |
+
st.markdown(f'<span style="font-size: 24px; color: green;">The 1st guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[3]])[2:-2]+".xyz"}</b> with a probability of {100*y_pred_proba[res[3]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
110 |
+
|
111 |
+
name = str(y_onehotenc_cat.categories_[0][res[0]])[2:-2]
|
112 |
+
if name.startswith("icsd"):
|
113 |
+
st.markdown(f'<span style="font-size: 24px; color: green;">The 1st guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[4]])[2:-2]+"cale.xyz"}</b> with a probability of {100*y_pred_proba[res[4]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
114 |
+
else:
|
115 |
+
st.markdown(f'<span style="font-size: 24px; color: green;">The 1st guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[4]])[2:-2]+".xyz"}</b> with a probability of {100*y_pred_proba[res[4]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
116 |
+
|
117 |
+
# st.markdown(f'<span style="font-size: 24px; color: green;">The 2nd guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[1]])[2:-2]+"cale.xyz"}</b> with a probability of {100*y_pred_proba[res[1]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
118 |
+
# st.markdown(f'<span style="font-size: 24px; color: green;">The 3rd guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[2]])[2:-2]+"cale.xyz"}</b> with a probability of {100*y_pred_proba[res[2]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
119 |
+
# st.markdown(f'<span style="font-size: 24px; color: green;">The 4th guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[3]])[2:-2]+"cale.xyz"}</b> with a probability of {100*y_pred_proba[res[3]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
120 |
+
# st.markdown(f'<span style="font-size: 24px; color: green;">The 5th guess from the model is: <b>{str(y_onehotenc_cat.categories_[0][res[4]])[2:-2]+"cale.xyz"}</b> with a probability of {100*y_pred_proba[res[4]]:.2f} %</span> <hr/>',unsafe_allow_html=True)
|
121 |
+
|
122 |
return res, y_pred_proba
|
123 |
|
124 |
# Define a download button to download the file
|
|
|
160 |
# Create and add the txt file with model guesses
|
161 |
with zipf.open("model_guesses.txt", "w") as f:
|
162 |
for i in range(5):
|
163 |
+
name = str(y_onehotenc_cat.categories_[0][res[i]])[2:-2]
|
164 |
if name.startswith("icsd"):
|
165 |
guess_text = f'The {i+1}st guess from the model is: {str(y_onehotenc_cat.categories_[0][res[i]])[2:-2]+"cale.xyz"} with a probability of {y_pred_proba[res[i]]:.2f} %\n'
|
166 |
f.write(guess_text.encode('utf-8'))
|