Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -47,17 +47,18 @@ def predict_product_batch():
|
|
| 47 |
file = request.files['file']
|
| 48 |
|
| 49 |
# Read the file into a DataFrame
|
| 50 |
-
|
|
|
|
| 51 |
input_data = input_data.drop(['Product_Id','Store_Establishment_Year','Product_Allocated_Area'],axis=1)
|
| 52 |
|
| 53 |
# Make predictions for the batch data
|
| 54 |
predictions = model.predict(input_data).tolist()
|
| 55 |
|
| 56 |
# Add predictions to the DataFrame
|
| 57 |
-
|
| 58 |
|
| 59 |
# Convert results to dictionary
|
| 60 |
-
result =
|
| 61 |
|
| 62 |
return jsonify(result)
|
| 63 |
|
|
|
|
| 47 |
file = request.files['file']
|
| 48 |
|
| 49 |
# Read the file into a DataFrame
|
| 50 |
+
data = pd.read_csv(file)
|
| 51 |
+
input_data = data.copy()
|
| 52 |
input_data = input_data.drop(['Product_Id','Store_Establishment_Year','Product_Allocated_Area'],axis=1)
|
| 53 |
|
| 54 |
# Make predictions for the batch data
|
| 55 |
predictions = model.predict(input_data).tolist()
|
| 56 |
|
| 57 |
# Add predictions to the DataFrame
|
| 58 |
+
data['Predicted_Product_Sales'] = predictions
|
| 59 |
|
| 60 |
# Convert results to dictionary
|
| 61 |
+
result = data.to_dict(orient="records")
|
| 62 |
|
| 63 |
return jsonify(result)
|
| 64 |
|