Spaces:
Sleeping
Sleeping
| import joblib | |
| import pandas as pd | |
| from flask import Flask, request, jsonify | |
| app = Flask("SuperKart Sales Predictor") | |
| model = joblib.load("superkart_model_v1_0.joblib") | |
| def home(): | |
| return "Welcome to the SuperKart Sales Prediction API" | |
| def predict_sales(): | |
| sales_data = request.get_json() | |
| sample = { | |
| "Product_Weight": sales_data['Product_Weight'], | |
| "Product_Sugar_Content": sales_data['Product_Sugar_Content'], | |
| "Product_Allocated_Area": sales_data['Product_Allocated_Area'], | |
| "Product_Type": sales_data['Product_Type'], | |
| "Product_MRP": sales_data['Product_MRP'], | |
| "Store_Establishment_Year": sales_data['Store_Establishment_Year'], | |
| "Store_Size": sales_data['Store_Size'], | |
| "Store_Location_City_Type": sales_data['Store_Location_City_Type'], | |
| "Store_Type": sales_data['Store_Type'] | |
| } | |
| input_data = pd.DataFrame([sample]) | |
| prediction = model.predict(input_data).tolist()[0] | |
| return jsonify({"Predicted Sales": prediction}) | |
| if __name__ == '__main__': | |
| app.run(debug=True) | |