saibsund commited on
Commit
481b699
·
verified ·
1 Parent(s): 4433828

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import pandas as pd
4
+ import requests
5
+
6
+ st.title('SuperKart Sales Forecast')
7
+
8
+ # Input fields with refined ranges based on df.describe()
9
+ product_weight = st.number_input('Product Weight', min_value=4.555, max_value=21.35, value=12.8289)
10
+ sugar_content = st.selectbox('Sugar Content', ['Low Sugar', 'Regular', 'No Sugar', 'reg'])
11
+ allocated_area = st.number_input('Allocated Area', min_value=0.013, max_value=0.295, value=0.1393)
12
+ 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'])
13
+ mrp = st.number_input('Product MRP', min_value=31.29, max_value=266.89, value=141.15)
14
+ est_year = st.number_input('Store Establishment Year', min_value=1985, max_value=2015, value=1998.81)
15
+ store_size = st.selectbox('Store Size', ['Medium', 'High', 'Small'])
16
+ city_type = st.selectbox('City Type', ['Tier 1', 'Tier 2', 'Tier 3'])
17
+ store_type = st.selectbox('Store Type', ['Supermarket Type1', 'Supermarket Type2', 'Departmental Store', 'Food Mart'])
18
+
19
+ if st.button('Predict'):
20
+ data = {
21
+ 'Product_Weight': product_weight,
22
+ 'Product_Sugar_Content': sugar_content,
23
+ 'Product_Allocated_Area': allocated_area,
24
+ 'Product_Type': product_type,
25
+ 'Product_MRP': mrp,
26
+ 'Store_Establishment_Year': est_year,
27
+ 'Store_Size': store_size,
28
+ 'Store_Location_City_Type': city_type,
29
+ 'Store_Type': store_type,
30
+ 'Store_Age': 2025 - est_year
31
+ }
32
+ try:
33
+ response = requests.post('https://saibsund-superkart-flask-api.hf.space/predict', json=data)
34
+ response.raise_for_status()
35
+ prediction = response.json()['prediction']
36
+ st.write(f'Predicted Sales: ${prediction:.2f}')
37
+ except requests.exceptions.RequestException as e:
38
+ st.write(f"Error: {e}")