| import streamlit as st |
| import pandas as pd |
| import joblib |
|
|
| |
| 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.") |
|
|
| |
| 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") |