IS361Group4 commited on
Commit
4c50283
·
verified ·
1 Parent(s): 06afa05

Update app.py

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