import streamlit as st import requests import pandas as pd import json st.title("SuperKart Sales Prediction") st.subheader("Online Superkart prediction") product_weight = st.number_input("Product Weight") product_area = st.number_input("Product_Allocated_Area") product_mrp = st.number_input("Product MRP(Rs)") age_of_store = st.number_input("Age of Store") store_size = st.selectbox("Store Size",["Small","Medium","High"]) store_city = st.selectbox("Store location citytype",["Tier 1","Tier 2", "Tier 3"]) product_type = st.selectbox("Product Type", ["Dairy", "Soft Drinks", "Meat", "Fruits and Vegetables", "Household", "Baking Goods", "Snack Foods", "Frozen Foods", "Breakfast", "Health and Hygiene", "Hard Drinks", "Canned", "Breads", "Starchy Foods", "Others", "Seafood" ]) product_sugar = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "High Sugar"]) store_type = st.selectbox("Store Type", ["Supermarket Type1", "Supermarket Type2","Food Mart","Departmental Store"]) input_data = { 'Product_Weight': product_weight, 'Product_Allocated_Area': product_area, 'Product_MRP': product_mrp, 'Age_Of_Store': age_of_store, 'Store_Size': store_size, 'Store_Location_City_Type': store_city, 'Product_Type': product_type, 'Product_Sugar_Content': product_sugar, 'Store_Type': store_type } if st.button("Sales Prediction"): api_url = "https://jpkarthikeyan-Superkart-Prediction-API.hf.space/predict" #api_url = "http://localhost:7860/predict" headers_info = {'Content-Type':'application/json'} try: #st.write(f"Prediction features",json.dumps(input_data.to_dict(oreient='records')[0],indent=2)) st.write(f"Prediction features",json.dumps(input_data,indent=2)) #response = requests.post(api_url, json=input_data.to_dict(orient='records')[0],headers=headers_info) response = requests.post(api_url, json=input_data,headers=headers_info) st.write(f"Status Code: {response.status_code}") if response.status_code == 200: result = response.json() st.write(response.text) # predicted_sales = result.get('prediction','No prediction retured') # print(f"Predicted store sales total: {predicted_sales}") else: st.write(f"Exception: {response.text}") except requests.exceptions.RequestException as ex: st.write(f"Exception: {ex}")