Spaces:
Sleeping
Sleeping
File size: 3,922 Bytes
36b054b 2a72ef1 c8166ff 522c77c abfcab6 564fde3 3c76263 c68f7bf 564fde3 886f866 4c50283 886f866 b9f45bd abfcab6 c2e007c abfcab6 db19c65 4c50283 f362d95 4c50283 f362d95 4c50283 f362d95 4c50283 f362d95 4c50283 f362d95 4c50283 f362d95 4c50283 f362d95 4c50283 886f866 4c50283 88068a7 db19c65 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
import gradio as gr
from churn_analysis import predict
from translator import text_translator_ui
from sentiment import create_sentiment_tab
from financial_analyst import create_financial_tab
from personal_info_identifier import create_personal_info_tab
with gr.Blocks() as app:
with gr.Tab("Text Translator"):
text_translator_ui()
with gr.Tab("Sentiment Analysis"):
create_sentiment_tab()
with gr.Tab("Financial Analyst"):
create_financial_tab()
with gr.Tab("Personal Info Identifier"):
gr.Interface.load("models/iiiorg/piiranha-v1-detect-personal-information")
with gr.Tab("Churn Analysis"):
gr.Markdown("Customer Churn Prediction")
# อธิบายเบื้องต้น
with gr.Row():
gr.Markdown("This app predicts the likelihood of a customer to leave or stay with the company.")
# กำหนด input columns
with gr.Row():
with gr.Column():
input_interface_column_1 = [
gr.Radio(['Yes', 'No'], label="Are you a Seniorcitizen?"),
gr.Radio(['Yes', 'No'], label='Do you have Partner?'),
gr.Radio(['No', 'Yes'], label='Do you have any Dependents?'),
gr.Slider(label='Enter length of Tenure in Months', minimum=1, maximum=73, step=1),
gr.Radio(['DSL', 'Fiber optic', 'No Internet'], label='What is your Internet Service?'),
gr.Radio(['No', 'Yes'], label='Do you have Online Security?'),
gr.Radio(['No', 'Yes'], label='Do you have Online Backup?'),
gr.Radio(['No', 'Yes'], label='Do you have Device Protection?')
]
with gr.Column():
input_interface_column_2 = [
gr.Radio(['No', 'Yes'], label='Do you have Tech Support?'),
gr.Radio(['No', 'Yes'], label='Do you have Streaming TV?'),
gr.Radio(['No', 'Yes'], label='Do you have Streaming Movies?'),
gr.Radio(['Month-to-month', 'One year', 'Two year'], label='What is your Contract Type?'),
gr.Radio(['Yes', 'No'], label='Do you prefer Paperless Billing?'),
gr.Radio(['Electronic check', 'Mailed check', 'Bank transfer (automatic)', 'Credit card (automatic)'], label='Which PaymentMethod do you prefer?'),
gr.Slider(label="Enter monthly charges", minimum=18.40, maximum=118.65)
]
# รวม inputs ไว้ในลิสต์เดียว
input_interface = []
input_interface.extend(input_interface_column_1)
input_interface.extend(input_interface_column_2)
# ปุ่มและผลลัพธ์
with gr.Row():
predict_btn = gr.Button('Predict')
output_interface = gr.Label(label="Churn Prediction Result")
# คำอธิบายเพิ่มเติม
with gr.Accordion("Open for information on inputs", open=False):
gr.Markdown("""
**Input Descriptions:**
- SeniorCitizen: Whether a customer is a senior citizen or not
- Partner: Whether the customer has a partner or not
- Dependents: Whether the customer has dependents
- Tenure: Number of months the customer has stayed
- InternetService, OnlineSecurity, OnlineBackup, DeviceProtection
- TechSupport, StreamingTV, StreamingMovies
- Contract: Type of contract (Month-to-month, One year, Two year)
- PaperlessBilling
- PaymentMethod
- MonthlyCharges
""")
# เชื่อมปุ่มกับฟังก์ชัน
predict_btn.click(fn=predict, inputs=input_interface, outputs=output_interface)
app.launch(share=True) |