Mummia-99 commited on
Commit
ec51633
·
verified ·
1 Parent(s): d928e51

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -5
app.py CHANGED
@@ -80,12 +80,34 @@ def values_prediction():
80
  type=st.selectbox("Select the type of Transaction:",options=option_type)
81
  type_value=option_type.index(type)
82
  if st.button('Submit'):
83
- output=model.predict([[step,type_value,amount]])
84
- if output == -1:
85
- st.write('Its not a Anomaly')
86
- else:
87
- st.write("Its a Anomaly")
 
 
 
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
 
91
 
 
80
  type=st.selectbox("Select the type of Transaction:",options=option_type)
81
  type_value=option_type.index(type)
82
  if st.button('Submit'):
83
+ try:
84
+ prediction=model.predict([[step,type_value,amount]])[0]
85
+
86
+ # Define messages and colors
87
+ review_status = {
88
+ -1: ("✅ Its not a Anomaly", "#32CD32"), # Green
89
+ 1: ("❌ Its a Anomaly ", "#FF4500") # Red-Orange
90
+ }
91
 
92
+ # Get message and color based on prediction
93
+ message, color = review_status.get(prediction, ("❓ Unknown Prediction", "#808080"))
94
+
95
+ # Display styled result
96
+ st.markdown(f"""
97
+ <div style="
98
+ padding: 15px;
99
+ background-color: {color};
100
+ border-radius: 10px;
101
+ text-align: center;
102
+ font-size: 18px;
103
+ font-weight: bold;
104
+ color: white;">
105
+ {message}
106
+ </div>
107
+ """, unsafe_allow_html=True)
108
+
109
+ except Exception as e:
110
+ st.error(f"⚠️ Error in prediction: {e}")
111
 
112
 
113