Update app.py
Browse files
app.py
CHANGED
|
@@ -210,25 +210,6 @@ with st.container():
|
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
-
# # --- Prediction Button & Result ---
|
| 214 |
-
# result_placeholder = st.empty() # ๐ Reserve space near the button
|
| 215 |
-
|
| 216 |
-
# if st.button("๐ Predict", key="predict", help="Click to see your personality"):
|
| 217 |
-
# prediction = knn.predict(final_input)[0]
|
| 218 |
-
# proba = knn.predict_proba(final_input)[0]
|
| 219 |
-
# label = prediction_labels.get(prediction, "โ Unknown")
|
| 220 |
-
# confidence = proba[prediction] * 100
|
| 221 |
-
|
| 222 |
-
# result_html = f"""
|
| 223 |
-
# <div class='result-box'>
|
| 224 |
-
# ๐ฎ <strong>Predicted Personality:</strong> {label}<br>
|
| 225 |
-
# ๐ <strong>Confidence:</strong> {confidence:.2f}%
|
| 226 |
-
# </div>
|
| 227 |
-
# """
|
| 228 |
-
# result_placeholder.markdown(result_html, unsafe_allow_html=True)
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
# --- Prediction Button & Result ---
|
| 233 |
result_placeholder = st.empty() # ๐ Reserve space near the button
|
| 234 |
|
|
@@ -236,19 +217,38 @@ with st.container():
|
|
| 236 |
prediction = knn.predict(final_input)[0]
|
| 237 |
proba = knn.predict_proba(final_input)[0]
|
| 238 |
label = prediction_labels.get(prediction, "โ Unknown")
|
|
|
|
| 239 |
|
| 240 |
result_html = f"""
|
| 241 |
<div class='result-box'>
|
| 242 |
-
๐ฎ <strong>Predicted Personality:</strong> {label}<br>
|
| 243 |
-
๐ <strong>
|
| 244 |
-
๐ Extrovert: {proba[0]*100:.2f}%<br>
|
| 245 |
-
๐ Introvert: {proba[1]*100:.2f}%
|
| 246 |
</div>
|
| 247 |
"""
|
| 248 |
result_placeholder.markdown(result_html, unsafe_allow_html=True)
|
| 249 |
|
| 250 |
|
| 251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
|
| 254 |
# # --- Prediction Button & Result ---
|
|
|
|
| 210 |
|
| 211 |
|
| 212 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
# --- Prediction Button & Result ---
|
| 214 |
result_placeholder = st.empty() # ๐ Reserve space near the button
|
| 215 |
|
|
|
|
| 217 |
prediction = knn.predict(final_input)[0]
|
| 218 |
proba = knn.predict_proba(final_input)[0]
|
| 219 |
label = prediction_labels.get(prediction, "โ Unknown")
|
| 220 |
+
confidence = proba[prediction] * 100
|
| 221 |
|
| 222 |
result_html = f"""
|
| 223 |
<div class='result-box'>
|
| 224 |
+
๐ฎ <strong>Predicted Personality:</strong> {label}<br>
|
| 225 |
+
๐ <strong>Confidence:</strong> {confidence:.2f}%
|
|
|
|
|
|
|
| 226 |
</div>
|
| 227 |
"""
|
| 228 |
result_placeholder.markdown(result_html, unsafe_allow_html=True)
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
+
# # --- Prediction Button & Result ---
|
| 233 |
+
# result_placeholder = st.empty() # ๐ Reserve space near the button
|
| 234 |
+
|
| 235 |
+
# if st.button("๐ Predict", key="predict", help="Click to see your personality"):
|
| 236 |
+
# prediction = knn.predict(final_input)[0]
|
| 237 |
+
# proba = knn.predict_proba(final_input)[0]
|
| 238 |
+
# label = prediction_labels.get(prediction, "โ Unknown")
|
| 239 |
+
|
| 240 |
+
# result_html = f"""
|
| 241 |
+
# <div class='result-box'>
|
| 242 |
+
# ๐ฎ <strong>Predicted Personality:</strong> {label}<br><br>
|
| 243 |
+
# ๐ <strong>Probabilities:</strong><br>
|
| 244 |
+
# ๐ Extrovert: {proba[0]*100:.2f}%<br>
|
| 245 |
+
# ๐ Introvert: {proba[1]*100:.2f}%
|
| 246 |
+
# </div>
|
| 247 |
+
# """
|
| 248 |
+
# result_placeholder.markdown(result_html, unsafe_allow_html=True)
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
|
| 252 |
|
| 253 |
|
| 254 |
# # --- Prediction Button & Result ---
|