File size: 545 Bytes
fbde87b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

import xgboost as xgb
import pandas as pd
import os
from preprocessing import preprocess_dataframe

# Sample training data
data = pd.DataFrame([
    {"last_premium_paid_date": "2023-06-15", "payment_mode": "Annual", "policy_term": 15, "policy_age": 3, "risk": 1},
    {"last_premium_paid_date": "2024-03-10", "payment_mode": "Monthly", "policy_term": 20, "policy_age": 2, "risk": 0},
])

X, y = preprocess_dataframe(data)
model = xgb.XGBClassifier()
model.fit(X, y)

os.makedirs("model", exist_ok=True)
model.save_model("model/xgb_model.json")