Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -37,20 +37,6 @@ def predict_sales():
|
|
| 37 |
# Convert the extracted data into a DataFrame
|
| 38 |
input_data = pd.DataFrame([requestData])
|
| 39 |
|
| 40 |
-
# create encoder with OneHotEncoder for encoding the selected values to match the training data
|
| 41 |
-
# encoder = OneHotEncoder(handle_unknown='ignore', sparse_output=False) # Important for handling unseen categories
|
| 42 |
-
|
| 43 |
-
# You MUST use the *trained* encoder to transform the new data
|
| 44 |
-
# encoded_new_data = encoder.transform(input_data[['Product_Sugar_Content','Product_Type','Store_Id','Store_Size','Store_Location_City_Type','Store_Type']])
|
| 45 |
-
|
| 46 |
-
#encoded_new_data = pd.get_dummies(
|
| 47 |
-
# input_data,
|
| 48 |
-
# columns=['Product_Sugar_Content','Product_Type','Store_Id','Store_Size','Store_Location_City_Type','Store_Type'],
|
| 49 |
-
# drop_first=True,
|
| 50 |
-
#);
|
| 51 |
-
#print("The data entered are below")
|
| 52 |
-
#print(encoded_new_data)
|
| 53 |
-
|
| 54 |
# Make a Sales prediction using the trained model
|
| 55 |
prediction = model.predict(input_data).tolist()[0]
|
| 56 |
|
|
@@ -61,4 +47,4 @@ def predict_sales():
|
|
| 61 |
predicted_sales = round(float(predicted_sales), 2)
|
| 62 |
|
| 63 |
# Return the prediction as a JSON response
|
| 64 |
-
return jsonify({'Predicted_Sale':
|
|
|
|
| 37 |
# Convert the extracted data into a DataFrame
|
| 38 |
input_data = pd.DataFrame([requestData])
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
# Make a Sales prediction using the trained model
|
| 41 |
prediction = model.predict(input_data).tolist()[0]
|
| 42 |
|
|
|
|
| 47 |
predicted_sales = round(float(predicted_sales), 2)
|
| 48 |
|
| 49 |
# Return the prediction as a JSON response
|
| 50 |
+
return jsonify({'Predicted_Sale': prediction})
|