Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +9 -13
- app.py +71 -0
- extraaLearn_prediction_model_v1_0.joblib +3 -0
- requirements.txt +6 -3
Dockerfile
CHANGED
|
@@ -1,20 +1,16 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
curl \
|
| 8 |
-
git \
|
| 9 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
-
|
| 11 |
-
COPY requirements.txt ./
|
| 12 |
-
COPY src/ ./src/
|
| 13 |
|
|
|
|
| 14 |
RUN pip3 install -r requirements.txt
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
| 19 |
|
| 20 |
-
|
|
|
|
| 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,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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("extraaLearn_prediction_model_v1_0.joblib")
|
| 11 |
+
|
| 12 |
+
model = load_model()
|
| 13 |
+
|
| 14 |
+
# Streamlit UI for Price Prediction
|
| 15 |
+
st.title("ExtraaLearn Customer Conversion Status Prediction App")
|
| 16 |
+
st.write("This tool predicts if an extraaLearn customer is likely to convert status.")
|
| 17 |
+
|
| 18 |
+
st.subheader("Enter the customer details:")
|
| 19 |
+
|
| 20 |
+
'age': eL_data['age'],
|
| 21 |
+
'website_visits': eL_data['website_visits'],
|
| 22 |
+
'time_spent_on_website': eL_data['time_spent_on_website'],
|
| 23 |
+
'page_views_per_visit': eL_data['page_views_per_visit'],
|
| 24 |
+
'current_occupation': eL_data['current_occupation'],
|
| 25 |
+
'first_interaction': eL_data['first_interaction'],
|
| 26 |
+
'profile_completed': eL_data['profile_completed'],
|
| 27 |
+
'last_activity': eL_data['last_activity'],
|
| 28 |
+
'print_media_type1': eL_data['print_media_type1'],
|
| 29 |
+
'print_media_type2': eL_data['print_media_type2'],
|
| 30 |
+
'digital_media': eL_data['digital_media'],
|
| 31 |
+
'educational_channels': eL_data['educational_channels'],
|
| 32 |
+
'referral' : eL_data['referral']
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
# Collect user input
|
| 36 |
+
age = st.number_input("age", min_value=14, step=1)
|
| 37 |
+
website_visits = st.number_input("website_visits", min_value=1, value=2)
|
| 38 |
+
time_spent_on_website = st.number_input("time_spent_on_website", min_value=1, step=1, value=2)
|
| 39 |
+
page_views_per_visit = st.number_input("page_views_per_visit", min_value=0.0, step=0.5)
|
| 40 |
+
current_occupation = st.selectbox("current_occupation", ["Professional", "Unemployed", "Student"])
|
| 41 |
+
first_interaction = st.selectbox("first_interaction", ["Website", "Mobile App"])
|
| 42 |
+
profile_completed = st.selectbox("profile_completed", ["Low - (0-50%)", "Medium - (50-75%)", "High (75-100%)"])
|
| 43 |
+
last_activity = st.selectbox("last_activity", ["Email Activity", "Phone Activity", "Website Activity"])
|
| 44 |
+
print_media_type1 = st.selectbox("print_media_type1", ["Yes", "No"])
|
| 45 |
+
print_media_type2 = st.selectbox("print_media_type2", ["Yes", "No"])
|
| 46 |
+
digital_media = st.selectbox("digital_media", ["Yes", "No"])
|
| 47 |
+
educational_channels = st.selectbox("educational_channels", ["Yes", "No"])
|
| 48 |
+
referral = st.selectbox("referral", ["Yes", "No"])
|
| 49 |
+
|
| 50 |
+
# Convert user input into a DataFrame
|
| 51 |
+
input_data = pd.DataFrame([{
|
| 52 |
+
'age': age,
|
| 53 |
+
'website_visits': website_visits,
|
| 54 |
+
'time_spent_on_website': time_spent_on_website,
|
| 55 |
+
'page_views_per_visit': page_views_per_visit,
|
| 56 |
+
'current_occupation': current_occupation,
|
| 57 |
+
'first_interaction': first_interaction,
|
| 58 |
+
'profile_completed': profile_completed,
|
| 59 |
+
'last_activity': last_activity,
|
| 60 |
+
'print_media_type1': print_media_type1,
|
| 61 |
+
'print_media_type2': print_media_type2,
|
| 62 |
+
'digital_media': digital_media,
|
| 63 |
+
'educational_channels': educational_channels,
|
| 64 |
+
'referral': referral
|
| 65 |
+
}])
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
# Predict button
|
| 69 |
+
if st.button("Predict"):
|
| 70 |
+
prediction = model.predict(input_data)
|
| 71 |
+
st.write(f"The predicted status for the customer is ${prediction[0]}.")
|
extraaLearn_prediction_model_v1_0.joblib
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:22a56d70ad13a93a04b5648256d2b61c84c7f72f6834f0f0ebb8f5724727d45c
|
| 3 |
+
size 55681
|
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
|