Spaces:
Sleeping
Sleeping
Force upload app.py - 1754764068
Browse files
app.py
CHANGED
|
@@ -69,9 +69,10 @@ def predict_sales():
|
|
| 69 |
# Reindex to match training columns (missing columns filled with 0)
|
| 70 |
input_final = input_encoded.reindex(columns=training_columns, fill_value=0)
|
| 71 |
|
| 72 |
-
#
|
| 73 |
-
|
| 74 |
-
|
|
|
|
| 75 |
|
| 76 |
return jsonify({
|
| 77 |
'prediction': float(prediction[0]),
|
|
|
|
| 69 |
# Reindex to match training columns (missing columns filled with 0)
|
| 70 |
input_final = input_encoded.reindex(columns=training_columns, fill_value=0)
|
| 71 |
|
| 72 |
+
# CRITICAL: Apply scaler ONLY to numerical columns (as done in training)
|
| 73 |
+
numerical_cols = ['Product_Weight', 'Product_MRP', 'Store_Age']
|
| 74 |
+
input_final[numerical_cols] = scaler.transform(input_final[numerical_cols])
|
| 75 |
+
prediction = model.predict(input_final)
|
| 76 |
|
| 77 |
return jsonify({
|
| 78 |
'prediction': float(prediction[0]),
|