File size: 777 Bytes
8f07d0e
f50f99c
6e509d7
 
 
f9f5174
 
f50f99c
6e509d7
f50f99c
6e509d7
 
f50f99c
6e509d7
 
491c0e0
f50f99c
6e509d7
e6cf2c9
6e509d7
f1a5823
f50f99c
6e509d7
 
df04160
6e509d7
 
df04160
6e509d7
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
import streamlit as st
import pandas as pd
import joblib

# Load model & features
model = joblib.load("src/final_model.pkl")
features = joblib.load("src/model_features.pkl")

st.set_page_config(page_title="Churn Prediction", layout="centered")

st.title("🔍 Customer Churn Prediction")
st.write("Enter customer information to predict churn probability.")

# User input
input_data = {}

for feature in features:
    input_data[feature] = st.number_input(feature, value=0.0)

input_df = pd.DataFrame([input_data])

if st.button("Predict"):
    proba = model.predict_proba(input_df)[0][1]
    st.metric("Churn Probability", f"{proba:.2%}")

    if proba > 0.5:
        st.error("⚠️ Customer is likely to churn")
    else:
        st.success("✅ Customer is likely to stay")