Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -264,23 +264,48 @@ if st.session_state.analysis_stage >= 2 and st.session_state.ensemble_result is
|
|
264 |
vote_ratio = vote_malicious / (vote_benign + vote_malicious)
|
265 |
st.progress(vote_ratio, text=f"Malicious vote ratio: {vote_ratio*100:.0f}%")
|
266 |
|
267 |
-
#
|
268 |
st.markdown("### Individual Model Results")
|
|
|
269 |
model_cols = st.columns(4)
|
|
|
270 |
with model_cols[0]:
|
271 |
st.markdown("**Random Forest**")
|
272 |
-
|
|
|
|
|
|
|
|
|
273 |
with model_cols[1]:
|
274 |
st.markdown("**SVM**")
|
275 |
-
|
|
|
|
|
|
|
|
|
276 |
with model_cols[2]:
|
277 |
st.markdown("**CNN**")
|
278 |
cnn_prob = results['cnn']['probability'] * 100
|
279 |
-
|
|
|
|
|
|
|
|
|
280 |
with model_cols[3]:
|
281 |
st.markdown("**LSTM**")
|
282 |
lstm_prob = results['lstm']['probability'] * 100
|
283 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
|
285 |
# Final ensemble verdict
|
286 |
st.markdown("### Ensemble Verdict")
|
|
|
264 |
vote_ratio = vote_malicious / (vote_benign + vote_malicious)
|
265 |
st.progress(vote_ratio, text=f"Malicious vote ratio: {vote_ratio*100:.0f}%")
|
266 |
|
267 |
+
# Display individual model results
|
268 |
st.markdown("### Individual Model Results")
|
269 |
+
|
270 |
model_cols = st.columns(4)
|
271 |
+
|
272 |
with model_cols[0]:
|
273 |
st.markdown("**Random Forest**")
|
274 |
+
if results['rf'] == 1:
|
275 |
+
st.error("⚠️ Malicious")
|
276 |
+
else:
|
277 |
+
st.success("✅ Safe")
|
278 |
+
|
279 |
with model_cols[1]:
|
280 |
st.markdown("**SVM**")
|
281 |
+
if results['svm'] == 1:
|
282 |
+
st.error("⚠️ Malicious")
|
283 |
+
else:
|
284 |
+
st.success("✅ Safe")
|
285 |
+
|
286 |
with model_cols[2]:
|
287 |
st.markdown("**CNN**")
|
288 |
cnn_prob = results['cnn']['probability'] * 100
|
289 |
+
if results['cnn']['prediction'] == 1:
|
290 |
+
st.error(f"⚠️ Malicious ({cnn_prob:.1f}%)")
|
291 |
+
else:
|
292 |
+
st.success(f"✅ Safe ({100-cnn_prob:.1f}%)")
|
293 |
+
|
294 |
with model_cols[3]:
|
295 |
st.markdown("**LSTM**")
|
296 |
lstm_prob = results['lstm']['probability'] * 100
|
297 |
+
if results['lstm']['prediction'] == 1:
|
298 |
+
st.error(f"⚠️ Malicious ({lstm_prob:.1f}%)")
|
299 |
+
else:
|
300 |
+
st.success(f"✅ Safe ({100-lstm_prob:.1f}%)")
|
301 |
+
|
302 |
+
# Final ensemble verdict
|
303 |
+
st.markdown("### Ensemble Verdict")
|
304 |
+
if results['ensemble'] == 1:
|
305 |
+
st.error("🚨 SQL Injection Detected by Majority Vote!")
|
306 |
+
else:
|
307 |
+
st.success("✅ Query deemed safe by majority vote")
|
308 |
+
|
309 |
|
310 |
# Final ensemble verdict
|
311 |
st.markdown("### Ensemble Verdict")
|