RPeltier commited on
Commit
cdae9fb
·
verified ·
1 Parent(s): adb25e4

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -6,7 +6,7 @@ from flask import Flask, request, jsonify
6
 
7
  # Initialize Flask app with a name
8
  app = Flask("Super Kart Product Pricing Predictor")
9
- saved_model = joblib.load("super_kart_product_pricing_model.joblib")
10
 
11
  # Define a route for the home page, used to validate backend is functional and accessible
12
  @app.get('/')
@@ -19,7 +19,6 @@ def predict_sales():
19
  # Get JSON data from the request
20
  data = request.get_json()
21
 
22
- print(f'data = {data}')
23
  # Extract relevant customer features from the input data. The order of the column names matters.
24
  sample = {
25
  'Product_Weight': data['Product_Weight'],
@@ -33,11 +32,10 @@ def predict_sales():
33
  'Product_Id_char': data['Product_Id_char'].astype(str),
34
  'Store_Age_Years': data['Store_Age_Years'],
35
  }
36
- print(f'sample = {sample}')
37
 
38
  # Convert the extracted data into a DataFrame and preprocess it
39
  input_data = pd.DataFrame([sample])
40
- prediction = saved_model.predict(input_data).tolist()[0]
41
 
42
  # Return the prediction as a JSON response
43
  return jsonify({'Predicted Product Price': prediction})
 
6
 
7
  # Initialize Flask app with a name
8
  app = Flask("Super Kart Product Pricing Predictor")
9
+ model = joblib.load("super_kart_product_pricing_model.joblib")
10
 
11
  # Define a route for the home page, used to validate backend is functional and accessible
12
  @app.get('/')
 
19
  # Get JSON data from the request
20
  data = request.get_json()
21
 
 
22
  # Extract relevant customer features from the input data. The order of the column names matters.
23
  sample = {
24
  'Product_Weight': data['Product_Weight'],
 
32
  'Product_Id_char': data['Product_Id_char'].astype(str),
33
  'Store_Age_Years': data['Store_Age_Years'],
34
  }
 
35
 
36
  # Convert the extracted data into a DataFrame and preprocess it
37
  input_data = pd.DataFrame([sample])
38
+ prediction = model.predict(input_data).tolist()[0]
39
 
40
  # Return the prediction as a JSON response
41
  return jsonify({'Predicted Product Price': prediction})