ahmad092 commited on
Commit
bde18e9
·
verified ·
1 Parent(s): 7aa78ec

Upload 3 files

Browse files
Files changed (3) hide show
  1. Apps.py +36 -0
  2. Requirements.txt +5 -0
  3. model.pkl +3 -0
Apps.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ import joblib
4
+ import numpy as np
5
+
6
+ # 1. Load the model
7
+ model = joblib.load('model.pkl')
8
+
9
+ # 2. Define the prediction function
10
+ def predict_churn(age, tenure, balance, salary):
11
+ # Prepare the input in the same format as your training data X
12
+ input_data = np.array([[age, tenure, balance, salary]])
13
+
14
+ # Get prediction
15
+ prediction = model.predict(input_data)
16
+
17
+ # Return human-readable result
18
+ return "Likely to EXIT" if prediction[0] == 1 else "Likely to STAY"
19
+
20
+ # 3. Create the Gradio Interface
21
+ demo = gr.Interface(
22
+ fn=predict_churn,
23
+ inputs=[
24
+ gr.Number(label="Age (Years)"),
25
+ gr.Slider(0, 10, step=1, label="Tenure (Years)"),
26
+ gr.Number(label="Account Balance"),
27
+ gr.Number(label="Estimated Annual Salary")
28
+ ],
29
+ outputs="text",
30
+ title="Customer Churn Predictor",
31
+ description="This model uses a Decision Tree (Optimized) to predict customer retention."
32
+ )
33
+
34
+ # 4. Launch
35
+ if __name__ == "__main__":
36
+ demo.launch()
Requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ pandas
2
+ numpy
3
+ scikit-learn
4
+ joblib
5
+ gradio
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:875ba9ea5af1860646993887d8e74cd466c3841565c2caf5e9fa4a1b1fcb556d
3
+ size 4089