import streamlit as st import pandas as pd import requests # Set the title of the Streamlit app st.title("Superkart Sales Prediction") # Section for online prediction st.subheader("Online Prediction") # Collect user input for property features store_type = st.selectbox("Store Type", ["Supermarket Type1", "Supermarket Type2", "Food Mart", "Departmental Store"]) store_location_city_type = st.selectbox("Store Location City Type", ['Tier 2' 'Tier 1' 'Tier 3']) store_size = st.selectbox("Store Size", ['Medium' 'High' 'Small']) store_id = st.selectbox("Store Id", ['OUT004' 'OUT003' 'OUT001' 'OUT002']) product_sugar_content = st.number_input("Product Sugar Content", ['Low Sugar', 'Regular', 'No Sugar']) 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']) # user_name = 'nrajwani' # repo_id = "nrajwani/SalesPredictionBackend" # Convert user input into a DataFrame input_data = pd.DataFrame([{ 'store_type': store_type, 'store_location_city_type': store_location_city_type, 'store_size': store_size, 'store_id': store_id, 'product_sugar_content': product_sugar_content, 'product_type': product_type }]) # Make prediction when the "Predict" button is clicked if st.button("Predict"): response = requests.post("https://-.hf.space/v1/sales", json=input_data.to_dict(orient='records')[0]) # Send data to Flask API if response.status_code == 200: prediction = response.json()['Predicted Sales (in dollars)'] st.success(f"Predicted Sales (in dollars): {prediction}") else: st.error("Error making prediction.") # Section for batch prediction st.subheader("Batch Prediction") # Allow users to upload a CSV file for batch prediction uploaded_file = st.file_uploader("Upload CSV file for batch prediction", type=["csv"]) # Make batch prediction when the "Predict Batch" button is clicked if uploaded_file is not None: if st.button("Predict Batch"): response = requests.post("https://-.hf.space/v1/salesbatch", files={"file": uploaded_file}) # Send file to Flask API if response.status_code == 200: predictions = response.json() st.success("Batch predictions completed!") st.write(predictions) # Display the predictions else: st.error("Error making batch prediction.")