Pushpak21 commited on
Commit
c353490
·
verified ·
1 Parent(s): a2cb479

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -12
app.py CHANGED
@@ -35,9 +35,6 @@ def predict():
35
  if missing:
36
  return jsonify({"error": f"Missing fields: {missing}"}), 400
37
 
38
- # Optional field
39
- desired_location = data.get("Location") # None if not given
40
-
41
  # Build DataFrame
42
  df = pd.DataFrame([{
43
  'Category': data['Category'],
@@ -57,6 +54,7 @@ def predict():
57
  X_query["Rank_log"] = df["Rank_log"]
58
  X_query["Percentage_bin"] = df["Percentage_bin"]
59
 
 
60
  for col in feature_columns:
61
  if col not in X_query.columns:
62
  X_query[col] = 0
@@ -83,7 +81,6 @@ def predict():
83
  row = choice_code_map.loc[int(choice_code)]
84
  college_name = row['College Name']
85
  course_name = row['Course Name']
86
-
87
  results.append({
88
  "rank": rank,
89
  "choice_code": int(choice_code),
@@ -92,13 +89,6 @@ def predict():
92
  "probability_percent": round(float(prob), 2)
93
  })
94
 
95
- # 🔷 Filter by Location if provided
96
- if desired_location:
97
- results = [
98
- r for r in results
99
- if desired_location.lower() in r["college_name"].lower()
100
- ]
101
-
102
  return jsonify({"top_20_predictions": results})
103
 
104
  except Exception as e:
@@ -109,4 +99,4 @@ def predict():
109
 
110
  # Run server
111
  if __name__ == '__main__':
112
- app.run(debug=False, host='0.0.0.0', port=7860)
 
35
  if missing:
36
  return jsonify({"error": f"Missing fields: {missing}"}), 400
37
 
 
 
 
38
  # Build DataFrame
39
  df = pd.DataFrame([{
40
  'Category': data['Category'],
 
54
  X_query["Rank_log"] = df["Rank_log"]
55
  X_query["Percentage_bin"] = df["Percentage_bin"]
56
 
57
+ # Ensure all training columns exist
58
  for col in feature_columns:
59
  if col not in X_query.columns:
60
  X_query[col] = 0
 
81
  row = choice_code_map.loc[int(choice_code)]
82
  college_name = row['College Name']
83
  course_name = row['Course Name']
 
84
  results.append({
85
  "rank": rank,
86
  "choice_code": int(choice_code),
 
89
  "probability_percent": round(float(prob), 2)
90
  })
91
 
 
 
 
 
 
 
 
92
  return jsonify({"top_20_predictions": results})
93
 
94
  except Exception as e:
 
99
 
100
  # Run server
101
  if __name__ == '__main__':
102
+ app.run(debug=False, host='0.0.0.0', port=7860)