IS361Group4 commited on
Commit
886f866
·
verified ·
1 Parent(s): dc0350d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -24
app.py CHANGED
@@ -8,37 +8,72 @@ with gr.Blocks() as app:
8
  text_translator_ui()
9
  pass
10
 
 
 
 
 
11
  # Add the Churn Analysis Tab
12
  with gr.Tab("Churn Analysis"):
13
  gr.Markdown("Customer Churn Prediction")
14
 
15
  # Define your inputs for churn prediction
16
  with gr.Row():
17
- input_interface = [
18
- gr.Radio(['Yes', 'No'], label="Are you a Senior Citizen?"),
19
- gr.Radio(['Yes', 'No'], label="Do you have a Partner?"),
20
- gr.Radio(['No', 'Yes'], label="Do you have Dependents?"),
21
- gr.Slider(minimum=1, maximum=73, step=1, label="Tenure (in months)"),
22
- gr.Radio(['DSL', 'Fiber optic', 'No Internet'], label="Internet Service"),
23
- gr.Radio(['No', 'Yes'], label="Do you have Online Security?"),
24
- gr.Radio(['No', 'Yes'], label="Do you have Online Backup?"),
25
- gr.Radio(['No', 'Yes'], label="Do you have Device Protection?"),
26
- gr.Radio(['No', 'Yes'], label="Do you have Tech Support?"),
27
- gr.Radio(['No', 'Yes'], label="Do you have Streaming TV?"),
28
- gr.Radio(['No', 'Yes'], label="Do you have Streaming Movies?"),
29
- gr.Radio(['Month-to-month', 'One year', 'Two year'], label="Contract Type"),
30
- gr.Radio(['Yes', 'No'], label="Paperless Billing?"),
31
- gr.Radio(['Electronic check', 'Mailed check', 'Bank transfer (automatic)', 'Credit card (automatic)'], label="Payment Method"),
32
- gr.Slider(minimum=18.40, maximum=118.65, label="Monthly Charges")
33
- ]
34
-
35
- output_interface = gr.Label(label="Churn Prediction")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
- predict_btn = gr.Button('Predict Churn')
38
- predict_btn.click(fn=predict, inputs=input_interface, outputs=output_interface)
39
 
40
- with gr.Tab("Sentiment Analysis"):
41
- sentiment_app = create_sentiment_tab()
42
- sentiment_app.launch
43
 
44
  app.launch(share=True)
 
8
  text_translator_ui()
9
  pass
10
 
11
+ with gr.Tab("Sentiment Analysis"):
12
+ sentiment_app = create_sentiment_tab()
13
+ sentiment_app.launch
14
+
15
  # Add the Churn Analysis Tab
16
  with gr.Tab("Churn Analysis"):
17
  gr.Markdown("Customer Churn Prediction")
18
 
19
  # Define your inputs for churn prediction
20
  with gr.Row():
21
+ gr.Markdown("This app predicts likelihood of a customer to leave or stay with the company")
22
+
23
+ with gr.Row():
24
+ with gr.Column():
25
+ input_interface_column_1 = [
26
+ gr.components.Radio(['Yes', 'No'], label="Are you a Seniorcitizen?"),
27
+ gr.components.Radio(['Yes', 'No'], label='Do you have Partner?'),
28
+ gr.components.Radio(['No', 'Yes'], label='Do you have any Dependents?'),
29
+ gr.components.Slider(label='Enter lenghth of Tenure in Months', minimum=1, maximum=73, step=1),
30
+ gr.components.Radio(['DSL', 'Fiber optic', 'No Internet'], label='What is your Internet Service?'),
31
+ gr.components.Radio(['No', 'Yes'], label='Do you have Online Security?'),
32
+ gr.components.Radio(['No', 'Yes'], label='Do you have Online Backup?'),
33
+ gr.components.Radio(['No', 'Yes'], label='Do you have Device Protection?')
34
+ ]
35
+
36
+ with gr.Column():
37
+ input_interface_column_2 = [
38
+ gr.components.Radio(['No', 'Yes'], label='Do you have Tech Support?'),
39
+ gr.components.Radio(['No', 'Yes'], label='Do you have Streaming TV?'),
40
+ gr.components.Radio(['No', 'Yes'], label='Do you have Streaming Movies?'),
41
+ gr.components.Radio(['Month-to-month', 'One year', 'Two year'], label='What is your Contract Type?'),
42
+ gr.components.Radio(['Yes', 'No'], label='Do you prefer Paperless Billing?'),
43
+ gr.components.Radio(['Electronic check', 'Mailed check', 'Bank transfer (automatic)', 'Credit card (automatic)'], label='Which PaymentMethod do you prefer?'),
44
+ gr.components.Slider(label="Enter monthly charges", minimum=18.40, maximum=118.65)
45
+ ]
46
+
47
+ with gr.Row():
48
+ input_interface.extend(input_interface_column_1)
49
+ input_interface.extend(input_interface_column_2)
50
+
51
+ with gr.Row():
52
+ predict_btn = gr.Button('Predict')
53
+ output_interface = gr.Label(label="churn")
54
+
55
+ with gr.Accordion("Open for information on inputs", open=False):
56
+ gr.Markdown("""This app receives the following as inputs and processes them to return the prediction on whether a customer, will churn or not.
57
+
58
+ - SeniorCitizen: Whether a customer is a senior citizen or not
59
+ - Partner: Whether the customer has a partner or not (Yes, No)
60
+ - Dependents: Whether the customer has dependents or not (Yes, No)
61
+ - Tenure: Number of months the customer has stayed with the company
62
+ - InternetService: Customer's internet service provider (DSL, Fiber Optic, No)
63
+ - OnlineSecurity: Whether the customer has online security or not (Yes, No, No Internet)
64
+ - OnlineBackup: Whether the customer has online backup or not (Yes, No, No Internet)
65
+ - DeviceProtection: Whether the customer has device protection or not (Yes, No, No internet service)
66
+ - TechSupport: Whether the customer has tech support or not (Yes, No, No internet)
67
+ - StreamingTV: Whether the customer has streaming TV or not (Yes, No, No internet service)
68
+ - StreamingMovies: Whether the customer has streaming movies or not (Yes, No, No Internet service)
69
+ - Contract: The contract term of the customer (Month-to-Month, One year, Two year)
70
+ - PaperlessBilling: Whether the customer has paperless billing or not (Yes, No)
71
+ - Payment Method: The customer's payment method (Electronic check, mailed check, Bank transfer(automatic), Credit card(automatic))
72
+ - MonthlyCharges: The amount charged to the customer monthly
73
+ """)
74
 
75
+ predict_btn.click(fn=predict, inputs=input_interface, outputs=output_interface)
76
+
77
 
 
 
 
78
 
79
  app.launch(share=True)