import streamlit as st import pandas as pd import requests # Set the title of the Streamlit app st.title("Superkart Price Prediction") # Section for online prediction st.subheader("Online Prediction") # Collect user input for property features product_weight = st.number_input("Product Weight", min_value=0.0) product_sugar_content = st.selectbox("Product Sugar Content", ['Low Sugar', 'Regular', 'No Sugar']) product_allocated_area = st.number_input("Product Allocated Area", min_value=0.0) product_type = st.selectbox("Product Type", ['Frozen Foods', 'Dairy', 'Canned', 'Baking Goods', 'Health and Hygiene', 'Snack Foods', 'Meat', 'Household', 'Hard Drinks', 'Fruits and Vegetables', 'Breads', 'Soft Drinks', 'Breakfast', 'Others', 'Starchy Foods', 'Seafood']) product_mrp = st.number_input("Product MRP", min_value=0.0) store_size = st.selectbox("Store Size", ['Medium', 'High', 'Small']) store_location_city_type = st.selectbox("Store Location City Type", ['Tier 2', 'Tier 1', 'Tier 3']) age_category = st.selectbox("Age_Category", ['0to20', '21to30', '31to50']) type_of_food = st.selectbox("type of food", ['Perishable', 'Non-Consumables', 'Non-Perishable']) # Convert user input into a DataFrame input_data = pd.DataFrame([{ 'product_weight': product_weight, 'product_sugar_content': product_sugar_content, 'product_allocated_area': product_allocated_area, 'product_type': product_type, 'product_mrp': product_mrp, 'store_size': store_size, 'store_location_city_type': store_location_city_type, 'age_category': age_category, 'type_of_food': type_of_food }]) # Make prediction when the "Predict" button is clicked if st.button("Predict"): response = requests.post("https://RedRooster99-projectbackend.hf.space/v1/superkart", json=input_data.to_dict(orient='records')[0]) # Send data to Flask API if response.status_code == 200: prediction = response.json()['Predicted Price'] st.success(f"Superkart Price: {prediction}") else: st.error("Error making prediction.")