Spaces:
Sleeping
Sleeping
import gradio as gr | |
from churn_analysis import predict | |
from translator import text_translator_ui | |
from sentiment import create_sentiment_tab | |
with gr.Blocks() as app: | |
with gr.Tab("Text Translator"): | |
text_translator_ui() | |
pass | |
with gr.Tab("Sentiment Analysis"): | |
sentiment_app = create_sentiment_tab() | |
# Add the Churn Analysis Tab | |
with gr.Tab("Churn Analysis"): | |
gr.Markdown("Customer Churn Prediction") | |
# Define your inputs for churn prediction | |
with gr.Row(): | |
gr.Markdown("This app predicts likelihood of a customer to leave or stay with the company") | |
with gr.Row(): | |
with gr.Column(): | |
input_interface_column_1 = [ | |
gr.components.Radio(['Yes', 'No'], label="Are you a Seniorcitizen?"), | |
gr.components.Radio(['Yes', 'No'], label='Do you have Partner?'), | |
gr.components.Radio(['No', 'Yes'], label='Do you have any Dependents?'), | |
gr.components.Slider(label='Enter lenghth of Tenure in Months', minimum=1, maximum=73, step=1), | |
gr.components.Radio(['DSL', 'Fiber optic', 'No Internet'], label='What is your Internet Service?'), | |
gr.components.Radio(['No', 'Yes'], label='Do you have Online Security?'), | |
gr.components.Radio(['No', 'Yes'], label='Do you have Online Backup?'), | |
gr.components.Radio(['No', 'Yes'], label='Do you have Device Protection?') | |
] | |
with gr.Column(): | |
input_interface_column_2 = [ | |
gr.components.Radio(['No', 'Yes'], label='Do you have Tech Support?'), | |
gr.components.Radio(['No', 'Yes'], label='Do you have Streaming TV?'), | |
gr.components.Radio(['No', 'Yes'], label='Do you have Streaming Movies?'), | |
gr.components.Radio(['Month-to-month', 'One year', 'Two year'], label='What is your Contract Type?'), | |
gr.components.Radio(['Yes', 'No'], label='Do you prefer Paperless Billing?'), | |
gr.components.Radio(['Electronic check', 'Mailed check', 'Bank transfer (automatic)', 'Credit card (automatic)'], label='Which PaymentMethod do you prefer?'), | |
gr.components.Slider(label="Enter monthly charges", minimum=18.40, maximum=118.65) | |
] | |
with gr.Row(): | |
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") | |
with gr.Accordion("Open for information on inputs", open=False): | |
gr.Markdown("""This app receives the following as inputs and processes them to return the prediction on whether a customer, will churn or not. | |
- SeniorCitizen: Whether a customer is a senior citizen or not | |
- Partner: Whether the customer has a partner or not (Yes, No) | |
- Dependents: Whether the customer has dependents or not (Yes, No) | |
- Tenure: Number of months the customer has stayed with the company | |
- InternetService: Customer's internet service provider (DSL, Fiber Optic, No) | |
- OnlineSecurity: Whether the customer has online security or not (Yes, No, No Internet) | |
- OnlineBackup: Whether the customer has online backup or not (Yes, No, No Internet) | |
- DeviceProtection: Whether the customer has device protection or not (Yes, No, No internet service) | |
- TechSupport: Whether the customer has tech support or not (Yes, No, No internet) | |
- StreamingTV: Whether the customer has streaming TV or not (Yes, No, No internet service) | |
- StreamingMovies: Whether the customer has streaming movies or not (Yes, No, No Internet service) | |
- Contract: The contract term of the customer (Month-to-Month, One year, Two year) | |
- PaperlessBilling: Whether the customer has paperless billing or not (Yes, No) | |
- Payment Method: The customer's payment method (Electronic check, mailed check, Bank transfer(automatic), Credit card(automatic)) | |
- MonthlyCharges: The amount charged to the customer monthly | |
""") | |
predict_btn.click(fn=predict, inputs=input_interface, outputs=output_interface) | |
app.launch(share=True) |