cmbtexas/project7benew
0
1 2import numpy as np3import joblib4import pandas as pd5from flask import Flask, request, jsonify6 7superkart_api = Flask("__main__")8model = joblib.load("rf_tuned_model_Superkart_sales_predication_model.joblib")9 10@superkart_api.get('/')11def home():12 return "Welcome to Chandra's Superkart Sales Prediction App"13 14@superkart_api.post('/predict')15def predict_sales():16 data = request.get_json()17 product_data= {18 'Product_Weight': data['Product_Weight'],19 'Product_Sugar_Content': data['Product_Sugar_Content'],20 'Product_Allocated_Area': data['Product_Allocated_Area'],21 'Product_MRP': data['Product_MRP'],22 'Store_Size': data['Store_Size'],23 'Store_Location_City_Type': data['Store_Location_City_Type'],24 'Store_Type': data['Store_Type'],25 'Product_Id_char': data['Product_Id_char'],26 'Store_Age_Years': data['Store_Age_Years'],27 'Product_Type_Category': data['Product_Type_Category']28 }29 30 input_data = pd.DataFrame([product_data])31 prediction = model.predict(input_data).tolist()[0]32 return jsonify({'Sales': prediction})33 34if __name__ == '__main__':35 superkart_api.run(debug=True)36 