File size: 1,109 Bytes
cf91b4b
 
 
 
 
 
f769f3c
cf91b4b
 
 
 
 
087ab15
f62028b
 
 
cf91b4b
 
42aa65f
 
 
 
 
 
 
 
 
cf91b4b
 
 
 
ea4bfb9
cf91b4b
7920370
cf91b4b
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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")

@app.get('/')
def home():
    return "Welcome to the SuperKart Sales Prediction API"

@app.post('/v1/sales')
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)