python - 预测契约(Contract)离散保单/条款的生存评分和 CLTV

标签 python survival-analysis cox-regression lifelines scikit-survival

我正在尝试用Python预测契约(Contract)和离散保单(保险中)的生存分数和LTV。我浏览了许多网站,但我可以找到许多仅适用于非契约(Contract)(零售)的示例。
我使用了以下代码:

from lifelines import CoxPHFitter
#After all feature selection and EDA

cph_train, cph_test = train_test_split(features, test_size=0.2)

cph = CoxPHFitter()
cph.fit(cph_train, 'TIME', event_col='EVENT')
cph.print_summary()

其中时间 - 对于活跃客户来说是保单生效日期与当前日期之间的天数,对于非活跃客户来说是保单生效日期与退保日期之间的天数。
EVENT - 指示客户是否活跃。

拟合模型后,我得到了 0.7 的一致性(我觉得还不错)。
从这里开始,我如何继续获得活跃客户的生存分数和终身值(value)(CLTV)? 基本上,我需要预测谁是会长期留在公司的有值(value)的客户。

我通过浏览 Cam 的一些帖子和建议添加了一些代码。

censored_subjects = features.loc[features['EVENT'] == 1] #Selecting only the ACTIVE ones

unconditioned_sf = cph.predict_survival_function(censored_subjects)

conditioned_sf = unconditioned_sf.apply(lambda c: (c / c.loc[features.loc[c.name, 'TIME']]).clip_upper(1)) 

predictions_75 = qth_survival_times(.75, conditioned_sf)
predictions_50 = qth_survival_times(.50, conditioned_sf)

values = predictions_75.T.join(data[['PREAMT','TIME']])
values50 = predictions_50.T.join(data[['PREAMT','TIME']])
values['RemainingValue'] = values['PREAMT'] * (values[0.75] - values['TIME'])

那么输出表示什么:
0.5 PREAMT TIME --- 第 0.5 列中的数字是否表示有 50% 机会关闭的持续时间?
0.75 PREAMT TIME --- 同样,0.75 表示有 75% 机会关闭的持续时间?
RemainingValue --- 是剩余要支付的金额吗?

此后下一步是什么?

最佳答案

Where TIME - is number of days between the policy taken date and current date for ACTIVE customers and between policy taken date and surrendered date for nonACTIVE customers. EVENT - is the indicator for whether the customer is ACTIVE or not ACTIVE.

对我来说很有意义。

After fitting the model I got concordance of 0.7(which I feel is OK).

对于生存模型来说,这是可以接受的分数👍但也可以尝试 AFT models ,这些可能会表现更好(也可以尝试 modelling all the parameters )。


因此,您下一步需要做的是预测客户的 future 生命周期,考虑他们已经度过了t时期。有some docs正是在这个应用程序上。请注意,相同的代码也适用于 AFT 型号。

您可以选择预测中位数或生存曲线。如果您的目标是 CLV,我认为预测生存曲线更合适,因为您可以对不同的保单利率进行建模(抱歉,我不知道正确的术语)。例如,使用文档中的代码:

times = np.arange(1000) # predict far out, since we don't want to truncate the survival curve prematurely. 
unconditioned_sf = cph.predict_survival_function(censored_subjects, times=times)

conditioned_sf = unconditioned_sf.apply(lambda c: (c / c.loc[df.loc[c.name, 'T']]).clip_upper(1))

# simple case, users pay $30 a month (and your units of survival function are "months"
CLV = (30 * conditioned_sf).sum(0)

# more complicated: they each have a different "rate"
CLV = conditioned_sf.sum(0) * rate_by_user

# and so on...

关于python - 预测契约(Contract)离散保单/条款的生存评分和 CLTV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56447131/

相关文章:

r - 如何将删失数据输入 R 的生存模型?

r - 使用时间相关系数和样条从 coxph 对象绘制估计的 HR

python - 这段 python 代码可以更高效吗?

python - 如何在mongoDB中自动存储插入的时间?

r - 将 ggsurvplot 中的 xlim 更改为笛卡尔坐标

machine-learning - 用于预测某些事件何时发生的机器学习模型

r - 外部函数调用中的 NA/NaN/Inf (arg 5)

python - theano 中的负对数似然(cox 回归)

python - 为什么 "except: pass"是一种糟糕的编程习惯?

python - Digikey零件价格python脚本