Spaces:
Runtime error
Runtime error
๐ Upload Flask + Docker backend files
Browse files
SuperKart_Sales_Predictor.py
CHANGED
|
@@ -24,7 +24,7 @@ def predict_sales():
|
|
| 24 |
"""
|
| 25 |
data = request.get_json()
|
| 26 |
|
| 27 |
-
#
|
| 28 |
sample = {
|
| 29 |
'Product_Weight': data['Product_Weight'],
|
| 30 |
'Product_Allocated_Area': data['Product_Allocated_Area'],
|
|
@@ -39,11 +39,12 @@ def predict_sales():
|
|
| 39 |
|
| 40 |
input_df = pd.DataFrame([sample])
|
| 41 |
|
| 42 |
-
# Ensure encoding matches model training (e.g., one-hot or label encoding)
|
| 43 |
-
# This assumes you used label encoding in preprocessing before model training
|
| 44 |
-
|
| 45 |
# Predict
|
| 46 |
predicted_sales = model.predict(input_df)[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
predicted_sales = round(float(predicted_sales), 2)
|
| 48 |
|
| 49 |
print("๐ Flask app is starting...")
|
|
|
|
| 24 |
"""
|
| 25 |
data = request.get_json()
|
| 26 |
|
| 27 |
+
# Extract relevant features from the JSON data
|
| 28 |
sample = {
|
| 29 |
'Product_Weight': data['Product_Weight'],
|
| 30 |
'Product_Allocated_Area': data['Product_Allocated_Area'],
|
|
|
|
| 39 |
|
| 40 |
input_df = pd.DataFrame([sample])
|
| 41 |
|
|
|
|
|
|
|
|
|
|
| 42 |
# Predict
|
| 43 |
predicted_sales = model.predict(input_df)[0]
|
| 44 |
+
|
| 45 |
+
# Calculate actual price
|
| 46 |
+
predicted_sales = np.exp(predicted_sales)
|
| 47 |
+
|
| 48 |
predicted_sales = round(float(predicted_sales), 2)
|
| 49 |
|
| 50 |
print("๐ Flask app is starting...")
|