shvuuuu commited on
Commit
d576c9e
1 Parent(s): 54c57fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -27
app.py CHANGED
@@ -1,10 +1,12 @@
1
  import gradio as gr
2
- import pandas as pd
3
  import pickle
 
 
4
  def example1():
5
 
6
- model=pickle.load("model.pkl")
7
- input_model = [[45,1.3,2,0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0,0, 0, 1]]
8
  pred=model.predict(input_model)
9
  churn = "False"
10
  if pred[0] == 1:
@@ -15,19 +17,7 @@ def example1():
15
 
16
  def example2():
17
 
18
- model=pickle.load("model.pkl")
19
- input_model = [[7,0.8,5,0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0,0, 0, 1]]
20
- pred=model.predict(input_model)
21
- churn = "False"
22
- if pred[0] == 0:
23
- churn = "She Will Churn"
24
- elif pred[0] == 1:
25
- churn = "She Will Not Churn"
26
- return churn
27
-
28
- def example3():
29
-
30
- model=pickle.load("model.pkl")
31
  input_model = [[41,2,2,0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0]]
32
  pred=model.predict(input_model)
33
  churn = "False"
@@ -38,9 +28,9 @@ def example3():
38
  return churn
39
 
40
 
41
- def example4():
42
 
43
- model=pickle.load("model.pkl")
44
  input_model = [[10,1.1,2,0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0]]
45
  pred=model.predict(input_model)
46
  churn = "False"
@@ -49,6 +39,18 @@ def example4():
49
  elif pred[0] == 0:
50
  churn = "He Will Not Churn"
51
  return churn
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
 
54
  def greet(Total_Transaction, Total_Ct_Chng_Q4_Q1, Total_Relationship_Count, Education=None, Annual_Income=None, Marital_Status=None, Card_Type=None):
@@ -94,7 +96,7 @@ def greet(Total_Transaction, Total_Ct_Chng_Q4_Q1, Total_Relationship_Count, Educ
94
 
95
 
96
  input_model = [[Total_Transaction,Total_Ct_Chng_Q4_Q1,Total_Relationship_Count,educ, edud, edug, eduh, edup, eduu, ai120, ai40, ai60, ai80, ai0, msd, msm, mss,ctb, ctg, cts]]
97
- model=pickle.load("model.pkl")
98
  pred=model.predict(input_model)
99
  churn = "False"
100
  if pred[0] == 1:
@@ -130,7 +132,7 @@ with gr.Blocks() as demo:
130
 
131
  with gr.Row():
132
  with gr.Column(scale=1,min_width=300):
133
- #gr.Image("/avatars/1.png")
134
  churn1 = gr.Textbox(value="", label="Churn")
135
  btn1 = gr.Button("PREDICT").style()
136
  exp =1
@@ -146,10 +148,10 @@ with gr.Blocks() as demo:
146
  Card Type - Silver\n
147
  """)
148
  with gr.Column(scale=2,min_width=300):
149
- #gr.Image("/avatars/4.png")
150
  churn2 = gr.Textbox(value="", label="Churn")
151
  bt2 = gr.Button("PREDICT").style()
152
- bt2.click(fn=example2, inputs=[], outputs=[churn2])
153
  gr.Markdown("""
154
  # Medical Professional!
155
  Total Transaction Count - 7\n
@@ -161,10 +163,10 @@ with gr.Blocks() as demo:
161
  Card Type - Gold\n
162
  """)
163
  with gr.Column(scale=3,min_width=300):
164
- #gr.Image("/avatars/2.png")
165
  churn3 = gr.Textbox(value="", label="Churn")
166
  btn3 = gr.Button("PREDICT").style()
167
- btn3.click(fn=example3, inputs=[], outputs=[churn3])
168
  gr.Markdown("""
169
  # Freelance Photographer!
170
  Total Transaction Count - 41\n
@@ -176,10 +178,10 @@ with gr.Blocks() as demo:
176
  Card Type - Blue\n
177
  """)
178
  with gr.Column(scale=4,min_width=300):
179
- #gr.Image("/avatars/3.png")
180
  churn4 = gr.Textbox(value="", label="Churn")
181
  btn4 = gr.Button("PREDICT").style()
182
- btn4.click(fn=example4, inputs=[], outputs=[churn4])
183
  gr.Markdown("""
184
  # Retired Veteran Pensioner!
185
  Total Transaction Count - 10\n
@@ -191,4 +193,4 @@ with gr.Blocks() as demo:
191
  Card Type - GOld\n
192
  """)
193
 
194
- demo.launch()
 
1
  import gradio as gr
2
+ import joblib
3
  import pickle
4
+ import pandas as pd
5
+
6
  def example1():
7
 
8
+ model = pickle.load(open('model.pkl', 'rb'))
9
+ input_model = [[65,1.8,2,0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1]]
10
  pred=model.predict(input_model)
11
  churn = "False"
12
  if pred[0] == 1:
 
17
 
18
  def example2():
19
 
20
+ model = pickle.load(open('/Users/shvuuuu/Downloads/Creditfile.pkl', 'rb'))
 
 
 
 
 
 
 
 
 
 
 
 
21
  input_model = [[41,2,2,0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0]]
22
  pred=model.predict(input_model)
23
  churn = "False"
 
28
  return churn
29
 
30
 
31
+ def example3():
32
 
33
+ model = pickle.load(open('/Users/shvuuuu/Downloads/Creditfile.pkl', 'rb'))
34
  input_model = [[10,1.1,2,0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0]]
35
  pred=model.predict(input_model)
36
  churn = "False"
 
39
  elif pred[0] == 0:
40
  churn = "He Will Not Churn"
41
  return churn
42
+
43
+ def example4():
44
+
45
+ model = pickle.load(open('/Users/shvuuuu/Downloads/Creditfile.pkl', 'rb'))
46
+ input_model = [[7,0.8,5,0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0,0, 0, 1]]
47
+ pred=model.predict(input_model)
48
+ churn = "False"
49
+ if pred[0] == 0:
50
+ churn = "She Will Churn"
51
+ elif pred[0] == 1:
52
+ churn = "She Will Not Churn"
53
+ return churn
54
 
55
 
56
  def greet(Total_Transaction, Total_Ct_Chng_Q4_Q1, Total_Relationship_Count, Education=None, Annual_Income=None, Marital_Status=None, Card_Type=None):
 
96
 
97
 
98
  input_model = [[Total_Transaction,Total_Ct_Chng_Q4_Q1,Total_Relationship_Count,educ, edud, edug, eduh, edup, eduu, ai120, ai40, ai60, ai80, ai0, msd, msm, mss,ctb, ctg, cts]]
99
+ model = pickle.load(open('/Users/shvuuuu/Downloads/Creditfile.pkl', 'rb'))
100
  pred=model.predict(input_model)
101
  churn = "False"
102
  if pred[0] == 1:
 
132
 
133
  with gr.Row():
134
  with gr.Column(scale=1,min_width=300):
135
+ gr.Image("avatars/1.png")
136
  churn1 = gr.Textbox(value="", label="Churn")
137
  btn1 = gr.Button("PREDICT").style()
138
  exp =1
 
148
  Card Type - Silver\n
149
  """)
150
  with gr.Column(scale=2,min_width=300):
151
+ gr.Image("avatars/4.png")
152
  churn2 = gr.Textbox(value="", label="Churn")
153
  bt2 = gr.Button("PREDICT").style()
154
+ bt2.click(fn=example4, inputs=[], outputs=[churn2])
155
  gr.Markdown("""
156
  # Medical Professional!
157
  Total Transaction Count - 7\n
 
163
  Card Type - Gold\n
164
  """)
165
  with gr.Column(scale=3,min_width=300):
166
+ gr.Image("avatars/2.png")
167
  churn3 = gr.Textbox(value="", label="Churn")
168
  btn3 = gr.Button("PREDICT").style()
169
+ btn3.click(fn=example2, inputs=[], outputs=[churn3])
170
  gr.Markdown("""
171
  # Freelance Photographer!
172
  Total Transaction Count - 41\n
 
178
  Card Type - Blue\n
179
  """)
180
  with gr.Column(scale=4,min_width=300):
181
+ gr.Image("avatars/3.png")
182
  churn4 = gr.Textbox(value="", label="Churn")
183
  btn4 = gr.Button("PREDICT").style()
184
+ btn4.click(fn=example3, inputs=[], outputs=[churn4])
185
  gr.Markdown("""
186
  # Retired Veteran Pensioner!
187
  Total Transaction Count - 10\n
 
193
  Card Type - GOld\n
194
  """)
195
 
196
+ demo.launch(share=True)