File size: 1,234 Bytes
c9494b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 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}.")