dschandra's picture
Upload 5 files
fbde87b verified
raw
history blame contribute delete
972 Bytes
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()