Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import gradio as gr
|
|
| 2 |
import joblib
|
| 3 |
import pandas as pd
|
| 4 |
|
| 5 |
-
# Load
|
| 6 |
model = joblib.load("model.pkl")
|
| 7 |
|
| 8 |
def predict(
|
|
@@ -15,10 +15,10 @@ def predict(
|
|
| 15 |
Store_Size,
|
| 16 |
Store_Location_City_Type,
|
| 17 |
Store_Type,
|
| 18 |
-
Product_Id_char
|
|
|
|
| 19 |
):
|
| 20 |
|
| 21 |
-
# Create DataFrame with correct column names
|
| 22 |
input_data = pd.DataFrame([{
|
| 23 |
"Product_Weight": Product_Weight,
|
| 24 |
"Product_Sugar_Content": Product_Sugar_Content,
|
|
@@ -29,15 +29,14 @@ def predict(
|
|
| 29 |
"Store_Size": Store_Size,
|
| 30 |
"Store_Location_City_Type": Store_Location_City_Type,
|
| 31 |
"Store_Type": Store_Type,
|
| 32 |
-
"Product_Id_char": Product_Id_char
|
|
|
|
| 33 |
}])
|
| 34 |
|
| 35 |
-
# Make prediction
|
| 36 |
prediction = model.predict(input_data)
|
| 37 |
return round(float(prediction[0]), 2)
|
| 38 |
|
| 39 |
|
| 40 |
-
# Gradio Interface
|
| 41 |
interface = gr.Interface(
|
| 42 |
fn=predict,
|
| 43 |
inputs=[
|
|
@@ -53,12 +52,11 @@ interface = gr.Interface(
|
|
| 53 |
["Grocery Store", "Supermarket Type1", "Supermarket Type2", "Supermarket Type3"],
|
| 54 |
label="Store Type"
|
| 55 |
),
|
| 56 |
-
gr.Textbox(label="Product ID Char")
|
|
|
|
| 57 |
],
|
| 58 |
outputs=gr.Number(label="Predicted Sales"),
|
| 59 |
-
title="🛒 SuperKart Sales Prediction"
|
| 60 |
-
description="Enter product and store details to predict sales"
|
| 61 |
)
|
| 62 |
|
| 63 |
-
# Launch app
|
| 64 |
interface.launch()
|
|
|
|
| 2 |
import joblib
|
| 3 |
import pandas as pd
|
| 4 |
|
| 5 |
+
# Load model
|
| 6 |
model = joblib.load("model.pkl")
|
| 7 |
|
| 8 |
def predict(
|
|
|
|
| 15 |
Store_Size,
|
| 16 |
Store_Location_City_Type,
|
| 17 |
Store_Type,
|
| 18 |
+
Product_Id_char,
|
| 19 |
+
Product_Type_Category
|
| 20 |
):
|
| 21 |
|
|
|
|
| 22 |
input_data = pd.DataFrame([{
|
| 23 |
"Product_Weight": Product_Weight,
|
| 24 |
"Product_Sugar_Content": Product_Sugar_Content,
|
|
|
|
| 29 |
"Store_Size": Store_Size,
|
| 30 |
"Store_Location_City_Type": Store_Location_City_Type,
|
| 31 |
"Store_Type": Store_Type,
|
| 32 |
+
"Product_Id_char": Product_Id_char,
|
| 33 |
+
"Product_Type_Category": Product_Type_Category
|
| 34 |
}])
|
| 35 |
|
|
|
|
| 36 |
prediction = model.predict(input_data)
|
| 37 |
return round(float(prediction[0]), 2)
|
| 38 |
|
| 39 |
|
|
|
|
| 40 |
interface = gr.Interface(
|
| 41 |
fn=predict,
|
| 42 |
inputs=[
|
|
|
|
| 52 |
["Grocery Store", "Supermarket Type1", "Supermarket Type2", "Supermarket Type3"],
|
| 53 |
label="Store Type"
|
| 54 |
),
|
| 55 |
+
gr.Textbox(label="Product ID Char"),
|
| 56 |
+
gr.Textbox(label="Product Type Category") # NEW FINAL ONE
|
| 57 |
],
|
| 58 |
outputs=gr.Number(label="Predicted Sales"),
|
| 59 |
+
title="🛒 SuperKart Sales Prediction"
|
|
|
|
| 60 |
)
|
| 61 |
|
|
|
|
| 62 |
interface.launch()
|