aenewton42 commited on
Commit
d055911
·
verified ·
1 Parent(s): a1dea01

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. app.py +52 -0
  2. churn_prediction_model_v1_0.joblib +3 -0
  3. requirements.txt +6 -0
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import pandas as pd
4
+ import joblib
5
+
6
+ # Load the trained model
7
+ def load_model():
8
+ return joblib.load("churn_prediction_model_v1_0.joblib")
9
+
10
+ model = load_model()
11
+
12
+ # Streamlit UI for Customer Churn Prediction
13
+ st.title("Telecom Customer Churn Prediction App")
14
+ st.write("This tool predicts customer churn risk based on their details. Enter the required information below.")
15
+
16
+ # Collect user input based on dataset columns
17
+ SeniorCitizen = st.selectbox("Senior citizen", ["Yes", "No"])
18
+ Partner = st.selectbox("Does the customer have a partner?", ["Yes", "No"])
19
+ Dependents = st.selectbox("Does the customer have dependents?", ["Yes", "No"])
20
+ PhoneService = st.selectbox("Does the customer have phone service?", ["Yes", "No"])
21
+ InternetService = st.selectbox("Type of Internet Service", ["DSL", "Fiber optic", "No"])
22
+ Contract = st.selectbox("Type of Contract", ["Month-to-month", "One year", "Two year"])
23
+ PaymentMethod = st.selectbox("Payment Method", ["Electronic check", "Mailed check", "Bank transfer", "Credit card"])
24
+ tenure = st.number_input("Tenure (Months with the company)", min_value=0, value=12)
25
+ MonthlyCharges = st.number_input("Monthly Charges", min_value=0.0, value=50.0)
26
+ TotalCharges = st.number_input("Total Charges", min_value=0.0, value=600.0)
27
+
28
+ # Convert categorical inputs to match model training
29
+ input_data = pd.DataFrame([{
30
+ 'SeniorCitizen': 1 if SeniorCitizen == "Yes" else 0,
31
+ 'Partner':Partner,
32
+ 'Dependents': Dependents,
33
+ 'tenure': tenure,
34
+ 'PhoneService': PhoneService,
35
+ 'InternetService': InternetService,
36
+ 'Contract': Contract,
37
+ 'PaymentMethod': PaymentMethod,
38
+ 'MonthlyCharges': MonthlyCharges,
39
+ 'TotalCharges': TotalCharges
40
+ }])
41
+
42
+
43
+ # Set classification threshold
44
+ classification_threshold = 0.5
45
+
46
+ # Predict button
47
+ # Predict button
48
+ if st.button("Predict"):
49
+ prediction_proba = model.predict_proba(input_data)[0, 1]
50
+ prediction = (prediction_proba >= classification_threshold).astype(int)
51
+ result = "churn" if prediction == 1 else "not churn"
52
+ st.write(f"Based on the information provided, the customer is likely to **{result}**.")
churn_prediction_model_v1_0.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1890379bd8a492620e028476e5e1c8f63cffabc25741b518f80a8c2ef11c919b
3
+ size 340069
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ pandas==2.2.2
2
+ numpy==2.0.2
3
+ scikit-learn==1.6.1
4
+ xgboost==2.1.4
5
+ joblib==1.4.2
6
+ streamlit==1.43.2