Spaces:
No application file
No application file
Upload folder using huggingface_hub
Browse files- app.py +46 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import requests
|
| 4 |
+
|
| 5 |
+
# Set the title of the Streamlit app
|
| 6 |
+
st.title("SuperKart sales Prediction")
|
| 7 |
+
|
| 8 |
+
# Section for online prediction
|
| 9 |
+
st.subheader("Online Prediction")
|
| 10 |
+
|
| 11 |
+
# Collect user input for Sales features
|
| 12 |
+
# Collect user input
|
| 13 |
+
product_Weight=st.number_input("Product_Weight", min_value=1, value=30.00)
|
| 14 |
+
product_Sugar_Content=st.selectbox("Product Sugar Content", ["Low Sugar", "No Sugar", "Regular"])
|
| 15 |
+
product_Allocated_Area=st.number_input("Product Allocate Area", min_value=0.001, value=0.09)
|
| 16 |
+
product_Type=st.selectbox("Product Type", ["meat", "snack foods", "hard drinks", "dairy", "canned", "soft drinks", "health and hygiene", "baking goods", "bread", "breakfast", "frozen foods", "fruits and vegetables", "household", "seafood", "starchy foods", "others"])
|
| 17 |
+
product_MRP=st.number_input("Product MRP", min_value=1, value=30.00)
|
| 18 |
+
store_Id=st.selectbox("Store ID", ["OUT001", "OUT002", "OUT003", "OUT004"])
|
| 19 |
+
store_Establishment_Year=st.number_input("Store Establishment year", min_value=1987, value=2009)
|
| 20 |
+
store_Size=st.selectbox("Store Size", ["High", "Medium", "Small"])
|
| 21 |
+
store_Location_City_Type=st.selectbox("Store location City", ["Tier1", "Tier2", "Tier3"])
|
| 22 |
+
store_Type=st.selectbox("Store Type", ["Departmental Store", "Supermarket Type 1", "Supermarket Type 2", "Food Mart"])
|
| 23 |
+
|
| 24 |
+
# Convert user input into a DataFrame
|
| 25 |
+
input_data = pd.DataFrame([{
|
| 26 |
+
'product_Weight': product_Weight,
|
| 27 |
+
'product_Sugar_Content': product_Sugar_Content,
|
| 28 |
+
'product_Allocated_Area': product_Allocated_Area,
|
| 29 |
+
'product_Type': product_Type,
|
| 30 |
+
'product_MRP': product_MRP,
|
| 31 |
+
'store_Id': store_Id,
|
| 32 |
+
'store_Establishment_Year': store_Establishment_Year,
|
| 33 |
+
'store_Size': store_Size,
|
| 34 |
+
'store_Location_City_Type': store_Location_City_Type,
|
| 35 |
+
'store_Type': store_Type
|
| 36 |
+
}])
|
| 37 |
+
|
| 38 |
+
# Make prediction when the "Predict" button is clicked
|
| 39 |
+
if st.button("Predict"):
|
| 40 |
+
response = requests.post("https://LalithaShiva-skproject.hf.space/v1/sksales", json=input_data.to_dict(orient='records')[0]) # Send data to Flask API
|
| 41 |
+
if response.status_code == 200:
|
| 42 |
+
result = response.json()['Predicted Price (in dollars)']
|
| 43 |
+
st.success(f"Predicted Rental Price (in dollars): {prediction}")
|
| 44 |
+
else:
|
| 45 |
+
st.error("Error making prediction.")
|
| 46 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pandas==2.2.2
|
| 2 |
+
requests==2.28.1
|