Backend / app.py
kameshwarink's picture
Update app.py
f363138 verified
import streamlit as st
import pandas as pd
import joblib
import numpy as np
# Load the trained model
@st.cache_resource
def load_model():
return joblib.load("extraaLearn_prediction_model_v1_0.joblib")
model = load_model()
# Streamlit UI for Price Prediction
st.title("ExtraaLearn Customer Conversion Status Prediction App")
st.write("This tool predicts if an extraaLearn customer is likely to convert status.")
st.subheader("Enter the customer details:")
'age': eL_data['age'],
'website_visits': eL_data['website_visits'],
'time_spent_on_website': eL_data['time_spent_on_website'],
'page_views_per_visit': eL_data['page_views_per_visit'],
'current_occupation': eL_data['current_occupation'],
'first_interaction': eL_data['first_interaction'],
'profile_completed': eL_data['profile_completed'],
'last_activity': eL_data['last_activity'],
'print_media_type1': eL_data['print_media_type1'],
'print_media_type2': eL_data['print_media_type2'],
'digital_media': eL_data['digital_media'],
'educational_channels': eL_data['educational_channels'],
'referral' : eL_data['referral']
# Collect user input
age = st.number_input("age", min_value=14, step=1)
website_visits = st.number_input("website_visits", min_value=1, value=2)
time_spent_on_website = st.number_input("time_spent_on_website", min_value=1, step=1, value=2)
page_views_per_visit = st.number_input("page_views_per_visit", min_value=0.0, step=0.5)
current_occupation = st.selectbox("current_occupation", ["Professional", "Unemployed", "Student"])
first_interaction = st.selectbox("first_interaction", ["Website", "Mobile App"])
profile_completed = st.selectbox("profile_completed", ["Low - (0-50%)", "Medium - (50-75%)", "High (75-100%)"])
last_activity = st.selectbox("last_activity", ["Email Activity", "Phone Activity", "Website Activity"])
print_media_type1 = st.selectbox("print_media_type1", ["Yes", "No"])
print_media_type2 = st.selectbox("print_media_type2", ["Yes", "No"])
digital_media = st.selectbox("digital_media", ["Yes", "No"])
educational_channels = st.selectbox("educational_channels", ["Yes", "No"])
referral = st.selectbox("referral", ["Yes", "No"])
# Convert user input into a DataFrame
input_data = pd.DataFrame([{
'age': age,
'website_visits': website_visits,
'time_spent_on_website': time_spent_on_website,
'page_views_per_visit': page_views_per_visit,
'current_occupation': current_occupation,
'first_interaction': first_interaction,
'profile_completed': profile_completed,
'last_activity': last_activity,
'print_media_type1': print_media_type1,
'print_media_type2': print_media_type2,
'digital_media': digital_media,
'educational_channels': educational_channels,
'referral': referral
}])
# Predict button
if st.button("Predict"):
prediction = model.predict(input_data)
st.write(f"The predicted status for the customer is {prediction[0]}.")