Update app.py
Browse files
app.py
CHANGED
|
@@ -28,16 +28,17 @@ def predict_tags_auto(title, description, threshold=0.2):
|
|
| 28 |
# Get probabilities for each tag
|
| 29 |
probas = model.predict_proba(input_vector)
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
probas_array = np.array([
|
| 33 |
|
| 34 |
# Apply threshold
|
| 35 |
predicted_binary = (probas_array >= threshold).astype(int).reshape(1, -1)
|
| 36 |
|
| 37 |
-
# Convert binary to tags
|
| 38 |
tags = mlb.inverse_transform(predicted_binary)
|
| 39 |
return tags[0] if tags else []
|
| 40 |
|
|
|
|
| 41 |
if st.button("Predict Tags"):
|
| 42 |
if not title.strip() or not description.strip():
|
| 43 |
st.warning("⚠️ Please enter both title and description.")
|
|
|
|
| 28 |
# Get probabilities for each tag
|
| 29 |
probas = model.predict_proba(input_vector)
|
| 30 |
|
| 31 |
+
# Get the probability for class=1 (relevant tag) for each classifier
|
| 32 |
+
probas_array = np.array([p[:, 1][0] for p in probas]) # (n_classes,)
|
| 33 |
|
| 34 |
# Apply threshold
|
| 35 |
predicted_binary = (probas_array >= threshold).astype(int).reshape(1, -1)
|
| 36 |
|
| 37 |
+
# Convert binary vector to tags
|
| 38 |
tags = mlb.inverse_transform(predicted_binary)
|
| 39 |
return tags[0] if tags else []
|
| 40 |
|
| 41 |
+
|
| 42 |
if st.button("Predict Tags"):
|
| 43 |
if not title.strip() or not description.strip():
|
| 44 |
st.warning("⚠️ Please enter both title and description.")
|