Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -23,11 +23,11 @@ def predict_product_sales_price():
|
|
| 23 |
sample = {
|
| 24 |
'Product_Weight': product_data['Product_Weight'],
|
| 25 |
'Product_Sugar_Content': product_data['Product_Sugar_Content'],
|
| 26 |
-
'Product_Allocated_Area': product_data['Product_Allocated_Area'],
|
| 27 |
'Product_Type': product_data['Product_Type'],
|
| 28 |
'Product_MRP': product_data['Product_MRP'],
|
| 29 |
'Store_Id': product_data['Store_Id'],
|
| 30 |
-
'
|
| 31 |
'Store_Size': product_data['Store_Size'],
|
| 32 |
'Store_Location_City_Type': product_data['Store_Location_City_Type'],
|
| 33 |
'Store_Type': product_data['Store_Type']
|
|
@@ -49,16 +49,22 @@ def predict_product_batch():
|
|
| 49 |
file = request.files['file']
|
| 50 |
|
| 51 |
# Read the file into a DataFrame
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
# Make predictions for the batch data
|
| 55 |
predictions = model.predict(input_data).tolist()
|
| 56 |
|
| 57 |
# Add predictions to the DataFrame
|
| 58 |
-
|
| 59 |
|
| 60 |
# Convert results to dictionary
|
| 61 |
-
result =
|
| 62 |
|
| 63 |
return jsonify(result)
|
| 64 |
|
|
|
|
| 23 |
sample = {
|
| 24 |
'Product_Weight': product_data['Product_Weight'],
|
| 25 |
'Product_Sugar_Content': product_data['Product_Sugar_Content'],
|
| 26 |
+
#'Product_Allocated_Area': product_data['Product_Allocated_Area'],
|
| 27 |
'Product_Type': product_data['Product_Type'],
|
| 28 |
'Product_MRP': product_data['Product_MRP'],
|
| 29 |
'Store_Id': product_data['Store_Id'],
|
| 30 |
+
'Store_Age': datetime.now().year - product_data['Store_Establishment_Year'],
|
| 31 |
'Store_Size': product_data['Store_Size'],
|
| 32 |
'Store_Location_City_Type': product_data['Store_Location_City_Type'],
|
| 33 |
'Store_Type': product_data['Store_Type']
|
|
|
|
| 49 |
file = request.files['file']
|
| 50 |
|
| 51 |
# Read the file into a DataFrame
|
| 52 |
+
data = pd.read_csv(file)
|
| 53 |
+
|
| 54 |
+
input_data = data.copy()
|
| 55 |
+
input_data['Store_Age'] = datetime.now().year - input_data['Store_Establishment_Year']
|
| 56 |
+
input_data = input_data.drop(['Product_Id','Store_Establishment_Year','Product_Allocated_Area'],axis=1)
|
| 57 |
+
|
| 58 |
+
|
| 59 |
|
| 60 |
# Make predictions for the batch data
|
| 61 |
predictions = model.predict(input_data).tolist()
|
| 62 |
|
| 63 |
# Add predictions to the DataFrame
|
| 64 |
+
data['Predicted_Product_Sales'] = predictions
|
| 65 |
|
| 66 |
# Convert results to dictionary
|
| 67 |
+
result = data.to_dict(orient="records")
|
| 68 |
|
| 69 |
return jsonify(result)
|
| 70 |
|