TokenTutor commited on
Commit
2fa985b
·
verified ·
1 Parent(s): 5c8db15

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -16,17 +16,18 @@ def home():
16
  # Define an endpoint to predict churn for a single customer
17
  @superkart_product_sales_prediction_api.post('/v1/forecast')
18
  def predict_sales_forecast():
19
- """
 
20
  This function handles POST requests to the '/v1/forecast' endpoint.
21
  It expects a JSON payload containing property details and returns
22
  the predicted rental price as a JSON response.
23
- """
24
 
25
  # Get JSON data from the request
26
- product_data = request.get_json()
27
 
28
- # Extract relevant customer features from the input data
29
- sample = {
30
  'Product_Weight': product_data.get('Product_Weight'),
31
  'Product_Sugar_Content': product_data.get('Product_Sugar_Content'),
32
  'Product_Allocated_Area': product_data.get('Product_Allocated_Area'),
@@ -39,18 +40,18 @@ def predict_sales_forecast():
39
  'Store_Type': product_data.get('Store_Type')
40
  }
41
 
42
- # Convert the extracted data into a DataFrame
43
- input_data = pd.DataFrame([sample])
44
 
45
- # Make a churn prediction using the trained model
46
- predicted_sales = model.predict(input_data).tolist()[0]
47
 
48
- # Convert predicted_price to Python float
49
- predicted_sales = round(float(predicted_sales), 2)
50
 
51
 
52
- # Return the prediction as a JSON response
53
- return jsonify({'Prediction': predicted_sales})
54
 
55
  @superkart_product_sales_prediction_api.post('/v1/forecastbatch')
56
  def predict_sales_forecast_batch():
 
16
  # Define an endpoint to predict churn for a single customer
17
  @superkart_product_sales_prediction_api.post('/v1/forecast')
18
  def predict_sales_forecast():
19
+
20
+ """
21
  This function handles POST requests to the '/v1/forecast' endpoint.
22
  It expects a JSON payload containing property details and returns
23
  the predicted rental price as a JSON response.
24
+ """
25
 
26
  # Get JSON data from the request
27
+ product_data = request.get_json()
28
 
29
+ # Extract relevant customer features from the input data
30
+ sample = {
31
  'Product_Weight': product_data.get('Product_Weight'),
32
  'Product_Sugar_Content': product_data.get('Product_Sugar_Content'),
33
  'Product_Allocated_Area': product_data.get('Product_Allocated_Area'),
 
40
  'Store_Type': product_data.get('Store_Type')
41
  }
42
 
43
+ # Convert the extracted data into a DataFrame
44
+ input_data = pd.DataFrame([sample])
45
 
46
+ # Make a churn prediction using the trained model
47
+ predicted_sales = model.predict(input_data).tolist()[0]
48
 
49
+ # Convert predicted_price to Python float
50
+ predicted_sales = round(float(predicted_sales), 2)
51
 
52
 
53
+ # Return the prediction as a JSON response
54
+ return jsonify({'Prediction': predicted_sales})
55
 
56
  @superkart_product_sales_prediction_api.post('/v1/forecastbatch')
57
  def predict_sales_forecast_batch():