Spaces:
Sleeping
Sleeping
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() | |