Santhu976 commited on
Commit
b4918d9
·
verified ·
1 Parent(s): cbf4f8c

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -8,7 +8,7 @@ from flask import Flask, request, jsonify # For creating the Flask API
8
  sales_total_predictor_api = Flask("SuperKart Sales Total Predictor")
9
 
10
  # Load the trained machine learning model
11
- model = joblib.load("product_stores_sales_total_prediction_model_v1_0.joblib")
12
 
13
  # Define a route for the home page (GET request)
14
  @sales_total_predictor_api.get('/')
@@ -72,14 +72,13 @@ def predict_sales_total_batch():
72
  # Read the CSV file into a Pandas DataFrame
73
  input_data = pd.read_csv(file)
74
 
75
- # Make predictions for all product and store in the DataFrame
76
  predicted_prices = model.predict(input_data).tolist()
77
 
78
  # Create a dictionary of predictions with property IDs as keys
79
- product_store_ids = input_data[['Product_Id', 'Store_Id']].values.tolist()
80
- keys = [f"{pid}_{sid}" for pid, sid in product_store_ids]
81
- output_dict = dict(zip(keys, predicted_prices))
82
-
83
  # Return the predictions dictionary as a JSON response
84
  return output_dict
85
 
 
8
  sales_total_predictor_api = Flask("SuperKart Sales Total Predictor")
9
 
10
  # Load the trained machine learning model
11
+ model = joblib.load("/content/drive/MyDrive/Colab Notebooks/Model Deployment/deployment_files/product_stores_sales_total_prediction_model_v1_0.joblib")
12
 
13
  # Define a route for the home page (GET request)
14
  @sales_total_predictor_api.get('/')
 
72
  # Read the CSV file into a Pandas DataFrame
73
  input_data = pd.read_csv(file)
74
 
75
+ # Make predictions for all product and store in the DataFrame
76
  predicted_prices = model.predict(input_data).tolist()
77
 
78
  # Create a dictionary of predictions with property IDs as keys
79
+ product_store_ids = input_data[['Product_Id', 'Store_Id']].values.tolist()
80
+ output_dict = dict(zip(product_store_ids, predicted_prices)) # Use actual prices
81
+
 
82
  # Return the predictions dictionary as a JSON response
83
  return output_dict
84