Spaces:
SRGL
/
Sleeping

File size: 2,505 Bytes
1cbb294
5639de5
 
1cbb294
5639de5
1cbb294
157042e
4ac99ec
b31ef55
4ac99ec
 
 
 
1cbb294
4ac99ec
1cbb294
b31ef55
 
 
 
 
 
 
 
 
 
4ac99ec
b31ef55
4ac99ec
 
 
 
 
b31ef55
 
 
 
4ac99ec
 
5639de5
4ac99ec
 
 
b31ef55
 
 
 
4ac99ec
b31ef55
 
 
 
4ac99ec
b31ef55
 
 
 
 
4ac99ec
b31ef55
4ac99ec
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
import joblib

st.title("Tourism Prediction App")

# Loading model
try:
    model = joblib.load("src/model.pkl")
    st.success("Model loaded successfully!")
except Exception as e:
    st.error(f"Model failed to load: {e}")
    st.stop()

st.header("Enter Customer Details")

# Numerical inputs
age = st.number_input("Age", 18, 100, 30)
income = st.number_input("Monthly Income", 0, 1000000, 50000)
duration_pitch = st.number_input("Duration Of Pitch", 0, 100, 10)
num_person = st.number_input("Number Of Persons Visiting", 1, 10, 2)
num_followups = st.number_input("Number Of Followups", 0, 10, 2)
num_trips = st.number_input("Number Of Trips", 0, 50, 5)
pitch_score = st.number_input("Pitch Satisfaction Score", 1, 5, 3)
children = st.number_input("Number Of Children Visiting", 0, 5, 0)
property_star = st.number_input("Preferred Property Star", 1, 5, 3)

# Categorical inputs
gender = st.selectbox("Gender", ["Male", "Female"])
marital = st.selectbox("Marital Status", ["Single", "Married"])
occupation = st.selectbox("Occupation", ["Salaried", "Self Employed", "Student"])
designation = st.selectbox("Designation", ["Manager", "Executive", "Senior Manager", "AVP", "VP"])
product = st.selectbox("Product Pitched", ["Basic", "Standard", "Deluxe", "Super Deluxe"])
contact = st.selectbox("Type of Contact", ["Company Invited", "Self Enquiry"])
city = st.selectbox("City Tier", [1, 2, 3])
passport = st.selectbox("Passport", [0, 1])
own_car = st.selectbox("Own Car", [0, 1])

# Prediction
if st.button("Predict"):
    try:
        input_df = pd.DataFrame([{
            "Age": age,
            "TypeofContact": contact,
            "CityTier": city,
            "DurationOfPitch": duration_pitch,
            "Occupation": occupation,
            "Gender": gender,
            "NumberOfPersonVisiting": num_person,
            "NumberOfFollowups": num_followups,
            "ProductPitched": product,
            "PreferredPropertyStar": property_star,
            "MaritalStatus": marital,
            "NumberOfTrips": num_trips,
            "Passport": passport,
            "PitchSatisfactionScore": pitch_score,
            "OwnCar": own_car,
            "NumberOfChildrenVisiting": children,
            "Designation": designation,
            "MonthlyIncome": income
        }])

        prediction = model.predict(input_df)
        st.success(f"Prediction: {prediction[0]}")

    except Exception as e:
        st.error(f"Error during prediction: {e}")