File size: 3,266 Bytes
f82743c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import streamlit as st
import pandas as pd
import numpy as np
import requests

st.write("Hello, Hugging Face!")


# # Streamlit UI for Super Kart Sales Prediction
# st.title("Super Kart Product Sales Prediction App")
# st.write("This tool predicts the total sales for a product based on store and product details.")

# st.subheader("Enter the product and store details:")

# # Collect user input (matching Super Kart features)
# product_weight = st.number_input("Product Weight", min_value=0.0, value=10.0, step=0.1)
# product_sugar_content = st.selectbox("Product Sugar Content", ["No Sugar", "Low Sugar", "Regular"])
# product_allocated_area = st.number_input("Product Allocated Area (sq ft)", min_value=0.0, value=500.0, step=1.0)
# product_type = st.selectbox("Product Type", ["Dairy", "Soft Drinks", "Meat", "Fruits and Vegetables", "Snack Foods", "Household", "Frozen Foods", "Baking Goods", "Canned", "Health and Hygiene", "Hard Drinks", "Breads", "Starchy Foods", "Breakfast", "Seafood", "Others"])
# product_mrp = st.number_input("Product MRP (price)", min_value=0.0, value=100.0, step=1.0)
# store_establishment_year = st.number_input("Store Establishment Year", min_value=1900, max_value=2025, value=2000, step=1)
# store_size = st.selectbox("Store Size", ["Small", "Medium", "High"])
# store_location_city_type = st.selectbox("Store Location City Type", ["Tier 3", "Tier 2", "Tier 1"])
# store_type = st.selectbox("Store Type", ["Grocery Store", "Supermarket Type1", "Supermarket Type2", "Supermarket Type3"])

# # Predict button
# if st.button("Predict"):
#     sample = {
#         '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_Establishment_Year': store_establishment_year,
#         'Store_Size': store_size,
#         'Store_Location_City_Type': store_location_city_type,
#         'Store_Type': store_type
#     }
    
#     features_df = pd.DataFrame([sample])
#     features_df = pd.get_dummies(features_df, columns=['Product_Type', 'Store_Type'], drop_first=True)
    
#     sugar_mapping = {'No Sugar': 0, 'Low Sugar': 1, 'Regular': 2}
#     size_mapping = {'Small': 0, 'Medium': 1, 'High': 2}
#     city_mapping = {'Tier 3': 0, 'Tier 2': 1, 'Tier 1': 2}
    
#     features_df['Product_Sugar_Content'] = features_df['Product_Sugar_Content'].map(sugar_mapping)
#     features_df['Store_Size'] = features_df['Store_Size'].map(size_mapping)
#     features_df['Store_Location_City_Type'] = features_df['Store_Location_City_Type'].map(city_mapping)
    
#     backend_url = "https://Hugo014-TotalSalesPredictionBackend.hf.space/v1/sales"
#     try:
#         response = requests.post(backend_url, json=sample)
#         if response.status_code == 200:
#             result = response.json()
#             predicted_sales = result['Predicted Sales Total (in dollars)']
#             st.write(f"The predicted sales total for the product is ${predicted_sales:.2f}.")
#         else:
#             st.error(f"Backend error: {response.status_code} - {response.text}")
#     except Exception as e:
#         st.error(f"Error calling backend: {str(e)}")