File size: 3,267 Bytes
b16d9a2
 
 
 
 
7430c14
b16d9a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c66c647
 
 
b16d9a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3f03ca9
 
4c0c6bf
 
3f03ca9
b16d9a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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.")