Update app.py
Browse files
app.py
CHANGED
|
@@ -95,7 +95,8 @@ def evaluate_model_with_report(val_loader):
|
|
| 95 |
def generate_performance_metrics():
|
| 96 |
y_pred = model.predict(X_test)
|
| 97 |
accuracy = accuracy_score(y_test,y_pred)
|
| 98 |
-
report = classification_report(y_test, y_pred, output_dict=True)
|
|
|
|
| 99 |
return {
|
| 100 |
"accuracy": f"{accuracy:.2%}",
|
| 101 |
"precision": f"{report['1']['precision']:.2%}",
|
|
@@ -108,7 +109,7 @@ def generate_performance_metrics():
|
|
| 108 |
def create_interface():
|
| 109 |
performance_metrics = generate_performance_metrics()
|
| 110 |
with gr.Blocks() as interface:
|
| 111 |
-
gr.Markdown("Spam Email
|
| 112 |
|
| 113 |
# Email Text Input
|
| 114 |
email_input = gr.Textbox(
|
|
@@ -120,7 +121,7 @@ def create_interface():
|
|
| 120 |
confidence_output = gr.Textbox(label="Confidence Score", interactive=False)
|
| 121 |
accuracy_output = gr.Textbox(label="Accuracy", interactive=False)
|
| 122 |
|
| 123 |
-
analyze_button = gr.Button("Analyze Email
|
| 124 |
|
| 125 |
def email_analysis_pipeline(email_text):
|
| 126 |
results = classify_email(email_text)
|
|
@@ -136,7 +137,7 @@ def create_interface():
|
|
| 136 |
fn=classify_email,
|
| 137 |
inputs=email_input,
|
| 138 |
outputs=[result_output, confidence_output, accuracy_output]
|
| 139 |
-
|
| 140 |
|
| 141 |
gr.Markdown("## 📊 Model Performance Analytics")
|
| 142 |
with gr.Row():
|
|
@@ -144,8 +145,8 @@ def create_interface():
|
|
| 144 |
gr.Textbox(value=performance_metrics["precision"], label="Precision", interactive=False)
|
| 145 |
gr.Textbox(value=performance_metrics["recall"], label="Recall", interactive=False)
|
| 146 |
gr.Textbox(value=performance_metrics["f1_score"], label="F1 Score", interactive=False)
|
| 147 |
-
|
| 148 |
-
|
| 149 |
|
| 150 |
# Launch the interface
|
| 151 |
interface = create_interface()
|
|
|
|
| 95 |
def generate_performance_metrics():
|
| 96 |
y_pred = model.predict(X_test)
|
| 97 |
accuracy = accuracy_score(y_test,y_pred)
|
| 98 |
+
report = classification_report(y_test, y_pred, output_dict=True)
|
| 99 |
+
|
| 100 |
return {
|
| 101 |
"accuracy": f"{accuracy:.2%}",
|
| 102 |
"precision": f"{report['1']['precision']:.2%}",
|
|
|
|
| 109 |
def create_interface():
|
| 110 |
performance_metrics = generate_performance_metrics()
|
| 111 |
with gr.Blocks() as interface:
|
| 112 |
+
gr.Markdown("Spam and Phishing Email Detection")
|
| 113 |
|
| 114 |
# Email Text Input
|
| 115 |
email_input = gr.Textbox(
|
|
|
|
| 121 |
confidence_output = gr.Textbox(label="Confidence Score", interactive=False)
|
| 122 |
accuracy_output = gr.Textbox(label="Accuracy", interactive=False)
|
| 123 |
|
| 124 |
+
analyze_button = gr.Button("Analyze Email")
|
| 125 |
|
| 126 |
def email_analysis_pipeline(email_text):
|
| 127 |
results = classify_email(email_text)
|
|
|
|
| 137 |
fn=classify_email,
|
| 138 |
inputs=email_input,
|
| 139 |
outputs=[result_output, confidence_output, accuracy_output]
|
| 140 |
+
)
|
| 141 |
|
| 142 |
gr.Markdown("## 📊 Model Performance Analytics")
|
| 143 |
with gr.Row():
|
|
|
|
| 145 |
gr.Textbox(value=performance_metrics["precision"], label="Precision", interactive=False)
|
| 146 |
gr.Textbox(value=performance_metrics["recall"], label="Recall", interactive=False)
|
| 147 |
gr.Textbox(value=performance_metrics["f1_score"], label="F1 Score", interactive=False)
|
| 148 |
+
|
| 149 |
+
return interface
|
| 150 |
|
| 151 |
# Launch the interface
|
| 152 |
interface = create_interface()
|