File size: 972 Bytes
fbde87b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

import gradio as gr
from predictor import predict_risk

def predict(policy_id, last_premium_paid_date, payment_mode, policy_term, policy_age):
    input_data = {
        "policy_id": policy_id,
        "last_premium_paid_date": last_premium_paid_date,
        "payment_mode": payment_mode,
        "policy_term": int(policy_term),
        "policy_age": int(policy_age)
    }
    risk = predict_risk(input_data)
    return {"Lapse Risk Score (0–1)": risk}

iface = gr.Interface(
    fn=predict,
    inputs=[
        gr.Textbox(label="Policy ID"),
        gr.Textbox(label="Last Premium Paid Date (YYYY-MM-DD)"),
        gr.Dropdown(["Annual", "Semi-Annual", "Quarterly", "Monthly"], label="Payment Mode"),
        gr.Number(label="Policy Term (Years)"),
        gr.Number(label="Policy Age (Years)")
    ],
    outputs="json",
    title="Lapse Risk Predictor",
    description="Enter policy details to predict the risk of lapse using an XGBoost model"
)

iface.launch()