Tenefix 80cols commited on
Commit
f2eadfb
·
verified ·
1 Parent(s): e05b6fd

interval prediction (#13)

Browse files

- interval prediction (f489eb8fddff981cbfbf647eea7232e8eaf3b4a9)


Co-authored-by: Sandro Ferroni <[email protected]>

Files changed (1) hide show
  1. predictor.py +17 -2
predictor.py CHANGED
@@ -76,11 +76,26 @@ def decrypt_prediction():
76
 
77
  # Interpret the prediction
78
  binary_prediction = int(np.argmax(decrypted_prediction))
79
- return "⚠️ Fraudulent ⚠️" if binary_prediction == 1 else "😊 Non-fraudulent 😊", gr.update(value="Decryption successful ✅")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
  except Exception as e:
82
  logging.error(f"Error during prediction: {e}")
83
- return "Error during prediction❌", "Error during prediction❌"
84
 
85
  def key_already_generated():
86
  """
 
76
 
77
  # Interpret the prediction
78
  binary_prediction = int(np.argmax(decrypted_prediction))
79
+ # Ensure the prediction is a flat array
80
+ if isinstance(decrypted_prediction, np.ndarray) and decrypted_prediction.ndim > 1:
81
+ decrypted_prediction = decrypted_prediction.flatten()
82
+
83
+ # Generate the HTML for the percentage bar
84
+ bar_html = f"""
85
+ <div style="width: 100%; background-color: lightgray; border-radius: 5px; overflow: hidden; display: flex;">
86
+ <div style="width: {decrypted_prediction[0] * 100}%; background-color: green; color: white; text-align: center; padding: 5px 0;">
87
+ {decrypted_prediction[0] * 100:.1f}% Non-Fraud
88
+ </div>
89
+ <div style="width: {decrypted_prediction[1] * 100}%; background-color: red; color: white; text-align: center; padding: 5px 0;">
90
+ {decrypted_prediction[1] * 100:.1f}% Fraud
91
+ </div>
92
+ </div>
93
+ """
94
+ return "⚠️ Fraudulent ⚠️" if binary_prediction == 1 else "😊 Non-fraudulent 😊", gr.update(value="Decryption successful ✅"), bar_html
95
 
96
  except Exception as e:
97
  logging.error(f"Error during prediction: {e}")
98
+ return "Error during prediction❌", "Error during prediction❌","Error during prediction❌"
99
 
100
  def key_already_generated():
101
  """