Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
13 |
|
14 |
-
# Add the Churn Analysis Tab
|
15 |
with gr.Tab("Churn Analysis"):
|
16 |
gr.Markdown("Customer Churn Prediction")
|
17 |
-
|
18 |
-
#
|
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.
|
26 |
-
gr.
|
27 |
-
gr.
|
28 |
-
gr.
|
29 |
-
gr.
|
30 |
-
gr.
|
31 |
-
gr.
|
32 |
-
gr.
|
33 |
]
|
34 |
-
|
35 |
with gr.Column():
|
36 |
input_interface_column_2 = [
|
37 |
-
gr.
|
38 |
-
gr.
|
39 |
-
gr.
|
40 |
-
gr.
|
41 |
-
gr.
|
42 |
-
gr.
|
43 |
-
gr.
|
44 |
]
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
50 |
with gr.Row():
|
51 |
predict_btn = gr.Button('Predict')
|
52 |
-
output_interface = gr.Label(label="
|
53 |
-
|
|
|
54 |
with gr.Accordion("Open for information on inputs", open=False):
|
55 |
-
gr.Markdown("""
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
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)
|