omm7 commited on
Commit
088ab9d
·
1 Parent(s): 2d43447

Upload frontend Streamlit files

Browse files
Files changed (3) hide show
  1. Dockerfile +16 -0
  2. requirements.txt +5 -0
  3. src/streamlit_app.py +17 -0
Dockerfile ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ streamlit
2
+ pandas
3
+ numpy
4
+ xgboost
5
+ scikit-learn
src/streamlit_app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import pickle
4
+
5
+ # load assets
6
+ with open("model/xgb_superkart_model.pkl", "rb") as f:
7
+ model = pickle.load(f)
8
+
9
+ X_test = pd.read_csv("data/X_test.csv")
10
+
11
+ # predict
12
+ preds = model.predict(X_test)
13
+
14
+ # output
15
+ st.title("SuperKart Sales Forecast")
16
+ st.subheader("X_test Predictions")
17
+ st.dataframe(pd.DataFrame({"Predicted Sales": preds}))