slickdata commited on
Commit
2c3fee3
·
1 Parent(s): 31a3ce9

Upload 5 files

Browse files
saved cap/02_cap.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
saved cap/Final_model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d76e5eb2277cb07b6faa1e6c40f29d496e9f33fa26ed423863fc1f690c1171f
3
+ size 1119
saved cap/app.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #import modules
2
+ import numpy as np
3
+ import gradio as gr
4
+ import joblib
5
+ import pandas as pd
6
+ import os
7
+
8
+
9
+ def load_model():
10
+ cwd = os.getcwd()
11
+
12
+ destination = os.path.join(cwd, "saved cap")
13
+
14
+ Final_model_file_path = os.path.join(destination, "Final_model.joblib")
15
+ preprocessor_file_path = os.path.join(destination, "preprocessor.joblib")
16
+
17
+
18
+ Final_model = joblib.load(Final_model_file_path)
19
+ preprocessor = joblib.load(preprocessor_file_path)
20
+
21
+
22
+ return Final_model, preprocessor
23
+
24
+ Final_model, preprocessor = load_model()
25
+
26
+
27
+ #define prediction function
28
+ def make_prediction(REGION, TENURE, MONTANT, FREQUENCE_RECH, REVENUE, ARPU_SEGMENT, FREQUENCE, DATA_VOLUME, ON_NET, ORANGE, TIGO, ZONE1, ZONE2,MRG, REGULARITY, FREQ_TOP_PACK):
29
+ #make a dataframe from input data
30
+ input_data = pd.DataFrame({'REGION':[REGION],
31
+ 'TENURE':[TENURE],
32
+ 'MONTANT':[MONTANT],
33
+ 'FREQUENCE_RECH':[FREQUENCE_RECH],
34
+ 'REVENUE':[REVENUE],
35
+ 'ARPU_SEGMENT':[ARPU_SEGMENT],
36
+ 'FREQUENCE':[FREQUENCE],
37
+ 'DATA_VOLUME':[DATA_VOLUME],
38
+ 'ON_NET':[ON_NET],
39
+ 'ORANGE':[ORANGE],
40
+ 'TIGO':[TIGO],
41
+ 'ZONE1':[ZONE1],
42
+ 'ZONE2':[ZONE2],
43
+ 'MRG':[MRG],
44
+ 'REGULARITY':[REGULARITY],
45
+ 'FREQ_TOP_PACK':[FREQ_TOP_PACK]})
46
+
47
+ transformer = preprocessor.transform(input_data)
48
+
49
+ predt = Final_model.predict(transformer)
50
+ #return prediction
51
+ if predt[0]==1:
52
+ return "Customer will Churn"
53
+ return "Customer will not Churn"
54
+
55
+
56
+ #create the input components for gradio
57
+ REGION = gr.inputs.Dropdown(choices =['DAKAR', 'THIES', 'SAINT-LOUIS', 'LOUGA', 'KAOLACK', 'DIOURBEL', 'TAMBACOUNDA' 'KAFFRINE,KOLDA', 'FATICK', 'MATAM', 'ZIGUINCHOR', 'SEDHIOU', 'KEDOUGOU'])
58
+ TENURE = gr.inputs.Dropdown(choices =['K > 24 month', 'I 18-21 month', 'H 15-18 month', 'G 12-15 month', 'J 21-24 month', 'F 9-12 month', 'E 6-9 month', 'D 3-6 month'])
59
+ MONTANT = gr.inputs.Number()
60
+ FREQUENCE_RECH = gr.Number()
61
+ REVENUE = gr.Number()
62
+ ARPU_SEGMENT = gr.Number()
63
+ FREQUENCE = gr.Number()
64
+ DATA_VOLUME = gr.Number()
65
+ ON_NET = gr.Number()
66
+ ORANGE = gr.Number()
67
+ TIGO = gr.Number()
68
+ ZONE1 = gr.Number()
69
+ ZONE2 = gr.Number()
70
+ MRG = gr.inputs.Dropdown(choices =['NO'])
71
+ REGULARITY = gr.Number()
72
+ FREQ_TOP_PACK = gr.Number()
73
+
74
+ output = gr.Textbox(label='Prediction')
75
+ #create the interface component
76
+
77
+ app = gr.Interface(fn =make_prediction,inputs =[REGION,
78
+ TENURE,
79
+ MONTANT,
80
+ FREQUENCE_RECH,
81
+ REVENUE,
82
+ ARPU_SEGMENT,
83
+ FREQUENCE,
84
+ DATA_VOLUME,
85
+ ON_NET,
86
+ ORANGE,
87
+ TIGO,
88
+ ZONE1,
89
+ ZONE2,
90
+ MRG,
91
+ REGULARITY,
92
+ FREQ_TOP_PACK],
93
+ title ="Customer Churn Predictor",
94
+ description="Enter the feilds Below and click the submit button to Make Your Prediction",
95
+ outputs = output)
96
+
97
+ app.launch(share = True, debug = True)
saved cap/preprocessor.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5cb13536b3299f65ac185dbcf617d8d8ea65c669d452669245675c75798c0a05
3
+ size 5424
saved cap/requirement.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ joblib
2
+ matplotlib
3
+ numpy
4
+ pandas
5
+ Pillow
6
+ protobuf
7
+ scikit-learn
8
+ gradio