amitcoolll's picture
Upload folder using huggingface_hub
c66c647 verified
import streamlit as st
import pandas as pd
import requests
# Set the title of the Streamlit app
st.title("Hi, Extraa Learn conversion Predictor")
# Section for conversion prediction
st.subheader("conversion Prediction")
# Collect user input for property features
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"])
# 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
}])
# Make prediction when the "Predict" button is clicked
if st.button("Predict"):
response = requests.post("https://amitcoolll-ExtraLearnConversionPredictionBackendAPP.hf.space/v1/conversion", json=input_data.to_dict(orient='records')[0]) # Send data to Flask API
if response.status_code == 200:
# prediction = response.json()['Predicted Status']
# prediction = response.json()['Status']
prediction = response.json()['Predicted Status']
st.success(f"Predicted Status: {prediction}")
else:
st.error("Error making prediction.")
# Section for batch prediction
st.subheader("Batch Prediction")
# Allow users to upload a CSV file for batch prediction
uploaded_file = st.file_uploader("Upload CSV file for batch prediction", type=["csv"])
# Make batch prediction when the "Predict Batch" button is clicked
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}) # Send file to Flask API
if response.status_code == 200:
predictions = response.json()
st.success("Batch predictions completed!")
st.write(predictions) # Display the predictions
else:
st.error("Error making batch prediction.")