Spaces:
No application file
No application file
commit app.py
Browse files
app.py
CHANGED
|
@@ -1,26 +1,49 @@
|
|
| 1 |
-
|
| 2 |
-
import joblib
|
| 3 |
import pandas as pd
|
| 4 |
-
|
| 5 |
-
|
| 6 |
|
| 7 |
# Load the trained model
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
# Make predictions
|
| 19 |
-
prediction = model.predict(input_df)
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
+
import joblib
|
| 4 |
+
import numpy as np
|
| 5 |
|
| 6 |
# Load the trained model
|
| 7 |
+
@st.cache_resource
|
| 8 |
+
def load_model():
|
| 9 |
+
return joblib.load("superkart_price_prediction_model_v1_0.joblib")
|
| 10 |
+
|
| 11 |
+
model = load_model()
|
| 12 |
+
|
| 13 |
+
# Streamlit UI for Price Prediction
|
| 14 |
+
st.title("SuperKart Rental Price Prediction App")
|
| 15 |
+
st.write("This tool predicts the price of an Superkart total sales based on the property type.")
|
| 16 |
+
|
| 17 |
+
st.subheader("Enter the listing details:")
|
| 18 |
|
| 19 |
+
# Collect user input
|
| 20 |
+
product_Weight=st.number_input("Product_Weight", min_value=1, value=30.00)
|
| 21 |
+
product_Sugar_Content=st.selectbox("Product Sugar Content", ["Low Sugar", "No Sugar", "Regular"])
|
| 22 |
+
product_Allocated_Area=st.number_input("Product Allocate Area", min_value=0.001, value=0.09)
|
| 23 |
+
product_Type=st.selectbox("Product Type", ["meat", "snack foods", "hard drinks", "dairy", "canned", "soft drinks", "health and hygiene", "baking goods", "bread", "breakfast", "frozen foods", "fruits and vegetables", "household", "seafood", "starchy foods", "others"])
|
| 24 |
+
product_MRP=st.number_input("Product MRP", min_value=1, value=30.00)
|
| 25 |
+
store_Id=st.selectbox("Store ID", ["OUT001", "OUT002", "OUT003", "OUT004"])
|
| 26 |
+
store_Establishment_Year=st.number_input("Store Establishment year", min_value=1987, value=2009)
|
| 27 |
+
store_Size=st.selectbox("Store Size", ["High", "Medium", "Small"])
|
| 28 |
+
store_Location_City_Type=st.selectbox("Store location City", ["Tier1", "Tier2", "Tier3"])
|
| 29 |
+
store_Type=st.selectbox("Store Type", ["Departmental Store", "Supermarket Type 1", "Supermarket Type 2", "Food Mart"])
|
| 30 |
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
# Convert user input into a DataFrame
|
| 33 |
+
input_data = pd.DataFrame([{
|
| 34 |
+
'product_Weight': product_Weight,
|
| 35 |
+
'product_Sugar_Content': product_Sugar_Content,
|
| 36 |
+
'product_Allocated_Area': product_Allocated_Area,
|
| 37 |
+
'product_Type': product_Type,
|
| 38 |
+
'product_MRP': product_MRP,
|
| 39 |
+
'store_Id': store_Id,
|
| 40 |
+
'store_Establishment_Year': store_Establishment_Year,
|
| 41 |
+
'store_Size': store_Size,
|
| 42 |
+
'store_Location_City_Type': store_Location_City_Type,
|
| 43 |
+
'store_Type': store_Type
|
| 44 |
+
}])
|
| 45 |
|
| 46 |
+
# Predict button
|
| 47 |
+
if st.button("Predict"):
|
| 48 |
+
prediction = model.predict(input_data)
|
| 49 |
+
st.write(f"The predicted price of the superkart sales is ${np.exp(prediction)[0]:.2f}.")
|