Upload folder using huggingface_hub
Browse files- Dockerfile +16 -21
- app.py +54 -0
- requirements.txt +6 -3
Dockerfile
CHANGED
|
@@ -1,21 +1,16 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
EXPOSE 8501
|
| 18 |
-
|
| 19 |
-
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
| 20 |
-
|
| 21 |
-
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
|
|
|
| 1 |
+
# Use a minimal base image with Python 3.9 installed
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
+
|
| 4 |
+
# Set the working directory inside the container to /app
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Copy all files from the current directory on the host to the container's /app directory
|
| 8 |
+
COPY . .
|
| 9 |
+
|
| 10 |
+
# Install Python dependencies listed in requirements.txt
|
| 11 |
+
RUN pip3 install -r requirements.txt
|
| 12 |
+
|
| 13 |
+
# Define the command to run the Streamlit app on port 8501 and make it accessible externally
|
| 14 |
+
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
|
| 15 |
+
|
| 16 |
+
# NOTE: Disable XSRF protection for easier external access in order to make batch predictions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import joblib
|
| 5 |
+
import numpy as np
|
| 6 |
+
|
| 7 |
+
# Load the trained model
|
| 8 |
+
@st.cache_resource
|
| 9 |
+
def load_model():
|
| 10 |
+
return joblib.load("SuperKart_turnOver_prediction_model_v1_0.joblib")
|
| 11 |
+
|
| 12 |
+
model = load_model()
|
| 13 |
+
|
| 14 |
+
# Streamlit UI for Price Prediction
|
| 15 |
+
st.title("Sales Revenue Prediction App")
|
| 16 |
+
st.write("This tool predicts the total revenue from a product.")
|
| 17 |
+
|
| 18 |
+
st.subheader("Enter the listing details:")
|
| 19 |
+
|
| 20 |
+
# Collect user input
|
| 21 |
+
Product_Weight = st.number_input("Weight of the product")
|
| 22 |
+
Product_Sugar_Content = st.selectbox("Sugar Content", ["Regular", "Low Sugar", "No Sugar"])
|
| 23 |
+
Product_Allocated_Area = st.number_input("Allocated area ratio(Ratio of the allocated display area of each product to the total display area of all the
|
| 24 |
+
products in a store)")
|
| 25 |
+
Product_Type = st.selectbox("Product_Type", [ "Baking Goods", "Breads", "Breakfast", "Canned", "Dairy", "Frozen Foods", "Fruits and Vegetables", "Hard Drinks", "Health and Hygiene", "Household", "Meat", "Seafood", "Snack Foods", "Soft Drinks", "Starchy Foods", "Others" ])
|
| 26 |
+
Product_MRP = st.number_input("Maximum retail price of the product")
|
| 27 |
+
Store_Id = st.text_input("Store ID (Example: OUT004)")
|
| 28 |
+
Store_Establishment_Year = st.number_input("Enter Year", min_value=1980, max_value=2025, step=1)
|
| 29 |
+
Store_Size = st.selectbox("Store size", ["Small", "Medium", "High"])
|
| 30 |
+
Store_Location_City_Type = st.selectbox("Type of city in which the store is located (Tier 1 consists of cities where the standard of living is comparatively higher than that of its Tier 2 and Tier 3 counterparts)", ["Tier 1", "Tier 2", "Tier 3"])
|
| 31 |
+
Store_Type = st.selectbox("Store Type", ["Departmental Store", "Food Mart", "Supermarket Type1", "Supermarket Type2"])
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
# Extract relevant customer features from the input data
|
| 35 |
+
sample = {
|
| 36 |
+
'Product_Weight': product_data['Product_Weight'],
|
| 37 |
+
'Product_Sugar_Content': product_data['Product_Sugar_Content'],
|
| 38 |
+
'Product_Allocated_Area': product_data['Product_Allocated_Area'],
|
| 39 |
+
'Product_Type': product_data['Product_Type'],
|
| 40 |
+
'Product_MRP': product_data['Product_MRP'],
|
| 41 |
+
'Store_Id': product_data['Store_Id'],
|
| 42 |
+
'Store_Establishment_Year': product_data['Store_Establishment_Year'],
|
| 43 |
+
'Store_Size ': product_data['Store_Size '],
|
| 44 |
+
'Store_Location_City_Type': product_data['Store_Location_City_Type'],
|
| 45 |
+
'Store_Type' : product_data['Store_Type']
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
# Convert the extracted data into a DataFrame
|
| 49 |
+
input_data = pd.DataFrame([sample])
|
| 50 |
+
|
| 51 |
+
# Predict button
|
| 52 |
+
if st.button("Predict"):
|
| 53 |
+
prediction = model.predict(input_data)
|
| 54 |
+
st.write(f"The predicted total revenue from the product is ${np.exp(prediction)[0]:.2f}.")
|
requirements.txt
CHANGED
|
@@ -1,3 +1,6 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pandas==2.2.2
|
| 2 |
+
numpy==2.0.2
|
| 3 |
+
scikit-learn==1.6.1
|
| 4 |
+
xgboost==2.1.4
|
| 5 |
+
joblib==1.4.2
|
| 6 |
+
streamlit==1.43.2
|