File size: 2,253 Bytes
5a31c46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
import requests

# Set the title of the Streamlit app
st.title("Extra Learn Status Prediction")

# Section for online prediction
st.subheader("Online Prediction")

# Collect user input for property features
age = st.number_input("age", min_value=1, value=75)
profile_completed = st.selectbox("profile_completed", ["Yes", "No"])
current_occupation = st.selectbox("current_occupation", ["Unemployed", "Professional", "Student"])
last_activity =st.selectbox("last_activity", ["Yes", "No"])
first_interaction = st.selectbox("first_interaction", ["Yes", "No"])
referral = st.selectbox("referral", ["Yes", "No"])
digital_media = st.selectbox("digital_media", ["Yes", "No"])

# Convert user input into a DataFrame
input_data = pd.DataFrame([{
        'age': age,
        'profile_completed': profile_completed,
        'current_occupation': current_occupation,
        'first_interaction': first_interaction,
        'last_activity':last_activity,
        'referral': referral,
        'digital_media': digital_media
}])


# Make prediction when the "Predict" button is clicked
if st.button("Predict"):
    response = requests.post("https://<username>-<repo_id>.hf.space/v1/rental", json=input_data.to_dict(orient='records')[0])  # Send data to Flask API
    if response.status_code == 200:
        prediction = response.json()['Predicted Status']
        st.success(f"Predicted Status: {prediction}")
    else:
        st.error("Error making prediction.")

# Section for batch prediction
st.subheader("Status Prediction")

# Allow users to upload a CSV file for batch prediction
uploaded_file = st.file_uploader("Upload CSV file for Status prediction", type=["csv"])

# Make batch prediction when the "Predict Batch" button is clicked
if uploaded_file is not None:
    if st.button("Predict Status"):
        response = requests.post("https://<username>-<repo_id>.hf.space/v1/rentalbatch", files={"file": uploaded_file})  # Send file to Flask API
        if response.status_code == 200:
            predictions = response.json()
            st.success("Status predictions completed!")
            st.write(predictions)  # Display the predictions
        else:
            st.error("Error making status prediction.")