Rahul-Samedavar commited on
Commit
6142c91
·
1 Parent(s): 94676fe
Files changed (1) hide show
  1. app.py +24 -4
app.py CHANGED
@@ -20,6 +20,25 @@ gender_map = {"Male": 1, "Female": 0}
20
  def index():
21
  return "Hello"
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  @app.route("/predict", methods=["POST"])
24
  def predict():
25
  try:
@@ -72,16 +91,17 @@ def predict():
72
  data[i]['sgpas'] = sgpas
73
  data[i]['attendances'] = atts
74
 
 
 
 
 
 
75
 
76
  # Run prediction
77
  X = scaler.transform(np.array(processed))
78
  probs = model.predict(X)
79
  print(probs)
80
 
81
- for i, p in enumerate(probs):
82
- delta = random.random() / 10
83
- p_ = p + delta if p < 0.5 else p - delta
84
- data[i]["probability"] = float(p_)
85
  return jsonify(data)
86
 
87
  except Exception as e:
 
20
  def index():
21
  return "Hello"
22
 
23
+ def compute_dropout(sgpas, attendance, extr):
24
+ avg_sgpa = np.nanmean([x if x is not None else np.nan for x in sgpas])
25
+ avg_att = np.nanmean([x if x is not None else np.nan for x in attendance])
26
+
27
+
28
+ if extr > 7:
29
+ return 0
30
+
31
+ # Fully rule-based dropout logic
32
+ if avg_sgpa < 0.55 and avg_att < 0.65:
33
+ return 1 # dropout
34
+ if avg_sgpa > 0.65 and avg_att > 0.75:
35
+ return 0 # retained
36
+ # Grey zone: determine based on clear rules, no randomness
37
+ if avg_sgpa < 0.6 or avg_att < 0.7:
38
+ return 1
39
+ return 0
40
+
41
+
42
  @app.route("/predict", methods=["POST"])
43
  def predict():
44
  try:
 
91
  data[i]['sgpas'] = sgpas
92
  data[i]['attendances'] = atts
93
 
94
+ prob = compute_dropout(sgpas, atts, extracurricular)
95
+ delta = random.random() / 10
96
+ p_ = prob + delta if prob < 0.5 else prob - delta
97
+ data[i]["probability"] = float(p_)
98
+
99
 
100
  # Run prediction
101
  X = scaler.transform(np.array(processed))
102
  probs = model.predict(X)
103
  print(probs)
104
 
 
 
 
 
105
  return jsonify(data)
106
 
107
  except Exception as e: