Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,18 +22,7 @@ def analyze_email(email_text):
|
|
| 22 |
confidence = max(prediction, 1 - prediction)
|
| 23 |
label = "Spam" if prediction > 0.5 else "Not Spam"
|
| 24 |
|
| 25 |
-
# Get feature importance
|
| 26 |
-
feature_names = tfidf.get_feature_names_out()
|
| 27 |
-
feature_importance = model.get_score(importance_type='gain')
|
| 28 |
-
top_features = sorted(feature_importance.items(), key=lambda x: x[1], reverse=True)[:5]
|
| 29 |
|
| 30 |
-
analysis = f"Classification: {label} (Confidence: {confidence:.2%})\n\n"
|
| 31 |
-
analysis += "Top 5 influential words:\n"
|
| 32 |
-
for feature, importance in top_features:
|
| 33 |
-
if feature in email_text.lower():
|
| 34 |
-
analysis += f"- {feature}: {importance:.2f}\n"
|
| 35 |
-
|
| 36 |
-
return analysis
|
| 37 |
|
| 38 |
# Create Gradio interface
|
| 39 |
with gr.Blocks(css="footer {visibility: hidden}") as iface:
|
|
@@ -72,10 +61,9 @@ with gr.Blocks(css="footer {visibility: hidden}") as iface:
|
|
| 72 |
The model achieved a 98% accuracy on the training data and 94% accuracy on the test data.
|
| 73 |
It analyzes the content and structure of the email to determine if it's spam or not.
|
| 74 |
|
| 75 |
-
###
|
| 76 |
- Enter the full text of the email for best results
|
| 77 |
-
|
| 78 |
-
- Confidence score indicates how sure the model is about its prediction
|
| 79 |
"""
|
| 80 |
)
|
| 81 |
|
|
|
|
| 22 |
confidence = max(prediction, 1 - prediction)
|
| 23 |
label = "Spam" if prediction > 0.5 else "Not Spam"
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
# Create Gradio interface
|
| 28 |
with gr.Blocks(css="footer {visibility: hidden}") as iface:
|
|
|
|
| 61 |
The model achieved a 98% accuracy on the training data and 94% accuracy on the test data.
|
| 62 |
It analyzes the content and structure of the email to determine if it's spam or not.
|
| 63 |
|
| 64 |
+
### Tip for use
|
| 65 |
- Enter the full text of the email for best results
|
| 66 |
+
|
|
|
|
| 67 |
"""
|
| 68 |
)
|
| 69 |
|