import joblib import pandas as pd from flask import Flask, request, jsonify # Libraries different ensemble classifiers from sklearn.ensemble import ( BaggingRegressor, RandomForestRegressor, AdaBoostRegressor, GradientBoostingRegressor, ) import xgboost as xgb # Initialize Flask app app = Flask("Supermarket Product Price Predictor") loaded_model = joblib.load("predict_product_price_v1_0.joblib") # Define a route for the home page # @sapp.get('/') # def home(): # return "Welcome to the Supermarket Product Price Predictor!" # Define an endpoint @app.post('/price') def predict_price(): # Get JSON data from the request input_json = request.get_json() # Convert the extracted data into a DataFrame input_data = pd.DataFrame([input_json]) # Make a churn prediction using the trained model prediction = loaded_model.predict(input_data) # Return the prediction as a JSON response return jsonify({'Price': prediction}) ## if __name__ == '__main__': # Run the app on all available interfaces on port 5000 app.run(debug=True, host='0.0.0.0', port=5000)