ccwizard commited on
Commit
985872b
·
verified ·
1 Parent(s): fd5dcc4

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -6,7 +6,7 @@ import pandas as pd # For data manipulation
6
  from flask import Flask, request, jsonify # For creating the Flask API
7
 
8
  # Initialize the Flask application
9
- rf_superkart_prediction_api = Flask("SuperKart Sales Prediction with Random Forest")
10
 
11
  # Load the trained machine learning model
12
  rf_model = joblib.load("superkart_sales_prediction_model_v1_0.joblib")
@@ -18,7 +18,7 @@ def home():
18
  This function handles GET requests to the root URL ('/') of the API.
19
  It returns a simple welcome message.
20
  """
21
- return "Welcome to the SuperKart Sales Prediction API with Random Forest!"
22
 
23
  # Define an endpoint for single property prediction (POST request)
24
  @rf_superkart_prediction_api.post('/v1/predict')
@@ -52,7 +52,7 @@ def predict_sales():
52
  input_data = pd.DataFrame([sample])
53
 
54
  # Make prediction (get log_price)
55
- sales_prediction = xgb_model.predict(input_data)[0]
56
 
57
  # Return the prediction
58
  return jsonify({'Sales': sales_prediction.tolist()})
@@ -60,8 +60,6 @@ def predict_sales():
60
  print(f"Error in prediction: {e}")
61
  return jsonify({'error': str(e)})
62
 
63
-
64
-
65
  # Run the Flask application in debug mode if this script is executed directly
66
  if __name__ == '__main__':
67
  rf_superkart_prediction_api.run(debug=True)
 
6
  from flask import Flask, request, jsonify # For creating the Flask API
7
 
8
  # Initialize the Flask application
9
+ rf_superkart_prediction_api = Flask("SuperKart Sales Prediction with XGBoost")
10
 
11
  # Load the trained machine learning model
12
  rf_model = joblib.load("superkart_sales_prediction_model_v1_0.joblib")
 
18
  This function handles GET requests to the root URL ('/') of the API.
19
  It returns a simple welcome message.
20
  """
21
+ return "Welcome to the SuperKart Sales Prediction API With Random Forest!"
22
 
23
  # Define an endpoint for single property prediction (POST request)
24
  @rf_superkart_prediction_api.post('/v1/predict')
 
52
  input_data = pd.DataFrame([sample])
53
 
54
  # Make prediction (get log_price)
55
+ sales_prediction = rf_model.predict(input_data)[0]
56
 
57
  # Return the prediction
58
  return jsonify({'Sales': sales_prediction.tolist()})
 
60
  print(f"Error in prediction: {e}")
61
  return jsonify({'error': str(e)})
62
 
 
 
63
  # Run the Flask application in debug mode if this script is executed directly
64
  if __name__ == '__main__':
65
  rf_superkart_prediction_api.run(debug=True)