samplespace / app.py
sasipriyank's picture
Upload folder using huggingface_hub
c9494b6 verified
import streamlit as st
import pandas as pd
import joblib
import numpy as np
# Load the trained model
@st.cache_resource
def load_model():
return joblib.load("superkart_prediction_model_v1_0.joblib")
model = load_model()
# Streamlit UI for Price Prediction
st.title("superkart Prediction App")
st.write("This tool predicts the sale details.")
st.subheader("Enter the listing details:")
# Collect user input
product_type = st.selectbox("Product Type", ["Product_Type", "Snack Foods", "Meat","Dairy","Household","Baking Goods","Fruits and Vegetables","Canned"])
product_weight = st.number_input("Product Weight", min_value=10, value=10)
Product_MRP = st.number_input("Product MRP", min_value=1, value=2)
Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Product_Sugar_Content", "Low Sugar", "No Sugar","Regular"])
# Convert user input into a DataFrame
input_data = pd.DataFrame([{
'product_type': product_type,
'product_weight': product_weight,
'Product_MRP': Product_MRP,
'Product_Sugar_Content': Product_Sugar_Content
}])
# Predict button
if st.button("Predict"):
prediction = model.predict(input_data)
st.write(f"The predicted price of the sale is ${np.exp(prediction)[0]:.2f}.")