Hemg commited on
Commit
6ed3494
·
verified ·
1 Parent(s): 1afdb11

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -11
app.py CHANGED
@@ -53,19 +53,24 @@ def predict_performance(Location, Course, College, Faculty, Source, Event, Prese
53
  print("\nDataFrame after encoding:")
54
  print(df)
55
 
56
- # Ensure the DataFrame has the same columns as the scaler was trained on
57
- expected_columns = scaler.feature_names_in_
58
- for col in expected_columns:
59
- if col not in df.columns:
60
- df[col] = 0 # Add missing columns with default value 0
61
-
62
- df = df[expected_columns] # Reorder columns to match the scaler's training data
63
-
64
-
 
 
 
 
 
 
65
 
66
-
67
  # Make the prediction
68
- prediction = model.predict(df)[0]
69
 
70
  # Clip the prediction to be between 0 and 1
71
  prediction = np.clip(prediction, 0, 1)
 
53
  print("\nDataFrame after encoding:")
54
  print(df)
55
 
56
+ # Extract features to scale
57
+ features_to_scale = df[["College Fee", "Year"]]
58
+
59
+ # Scale only the College Fee and Year
60
+ scaled_features = scaler.transform(features_to_scale)
61
+
62
+ # Replace the original features with the scaled features
63
+ df[["College Fee", "Year"]] = scaled_features
64
+
65
+ # Debug print: Show DataFrame after scaling
66
+ print("\nDataFrame after scaling:")
67
+ print(df)
68
+
69
+ # Prepare the input for the model
70
+ model_input = df.values # Convert DataFrame to numpy array for model input
71
 
 
72
  # Make the prediction
73
+ prediction = model.predict(model_input)[0]
74
 
75
  # Clip the prediction to be between 0 and 1
76
  prediction = np.clip(prediction, 0, 1)