|
|
import streamlit as st |
|
|
import pandas as pd |
|
|
import requests |
|
|
|
|
|
|
|
|
st.title("Hi, Extraa Learn conversion Predictor") |
|
|
|
|
|
|
|
|
st.subheader("conversion Prediction") |
|
|
|
|
|
|
|
|
|
|
|
age = st.number_input("age", min_value=1, value=65) |
|
|
website_visits = st.number_input("website_visits", min_value=0, value=30) |
|
|
time_spent_on_website = st.number_input("time_spent_on_website", min_value=0, value=2000) |
|
|
page_views_per_visit = st.number_input("page_views_per_visit", min_value=0, value=20) |
|
|
current_occupation = st.selectbox("current occupation", ["professional", "unemployed", "student"]) |
|
|
first_interaction = st.selectbox("first interaction", ["Website", "Mobile App"]) |
|
|
profile_completed = st.selectbox("profile completed", ["High", "medium", "Low"]) |
|
|
last_activity = st.selectbox("last activity", ["Email Activity", "Phone Activity", "Website Activity"]) |
|
|
print_media_type1 = st.selectbox("media type1", ["yes", "NO"]) |
|
|
print_media_type2 = st.selectbox("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"]) |
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
}]) |
|
|
|
|
|
|
|
|
if st.button("Predict"): |
|
|
response = requests.post("https://amitcoolll-ExtraLearnConversionPredictionBackendAPP.hf.space/v1/conversion", json=input_data.to_dict(orient='records')[0]) |
|
|
if response.status_code == 200: |
|
|
|
|
|
|
|
|
prediction = response.json()['Predicted Status'] |
|
|
st.success(f"Predicted Status: {prediction}") |
|
|
|
|
|
else: |
|
|
st.error("Error making prediction.") |
|
|
|
|
|
|
|
|
st.subheader("Batch Prediction") |
|
|
|
|
|
|
|
|
uploaded_file = st.file_uploader("Upload CSV file for batch prediction", type=["csv"]) |
|
|
|
|
|
|
|
|
if uploaded_file is not None: |
|
|
if st.button("Predict Batch"): |
|
|
response = requests.post("https://amitcoolll-ExtraLearnConversionPredictionBackendAPP.hf.space/v1/conversionbatch", files={"file": uploaded_file}) |
|
|
if response.status_code == 200: |
|
|
predictions = response.json() |
|
|
st.success("Batch predictions completed!") |
|
|
st.write(predictions) |
|
|
else: |
|
|
st.error("Error making batch prediction.") |
|
|
|