Esempio n. 1
0
def test_pipeline():
    tri = cl.load_sample('clrd').groupby('LOB').sum()[[
        'CumPaidLoss', 'IncurLoss', 'EarnedPremDIR'
    ]]
    tri['CaseIncurredLoss'] = tri['IncurLoss'] - tri['CumPaidLoss']

    X = tri[['CumPaidLoss', 'CaseIncurredLoss']]
    sample_weight = tri['EarnedPremDIR'].latest_diagonal

    dev = [
        cl.Development(),
        cl.ClarkLDF(),
        cl.Trend(),
        cl.IncrementalAdditive(),
        cl.MunichAdjustment(paid_to_incurred=('CumPaidLoss',
                                              'CaseIncurredLoss')),
        cl.CaseOutstanding(paid_to_incurred=('CumPaidLoss',
                                             'CaseIncurredLoss'))
    ]
    tail = [cl.TailCurve(), cl.TailConstant(), cl.TailBondy(), cl.TailClark()]
    ibnr = [
        cl.Chainladder(),
        cl.BornhuetterFerguson(),
        cl.Benktander(n_iters=2),
        cl.CapeCod()
    ]

    for model in list(itertools.product(dev, tail, ibnr)):
        print(model)
        cl.Pipeline(
            steps=[('dev',
                    model[0]), ('tail',
                                model[1]), ('ibnr', model[2])]).fit_predict(
                                    X, sample_weight=sample_weight).ibnr_.sum(
                                        'origin').sum('columns').sum()
Esempio n. 2
0
def test_schmidt():
    tri = cl.load_dataset('ia_sample')
    ia = cl.IncrementalAdditive()
    answer = ia.fit_transform(tri.iloc[0, 1],
                              sample_weight=tri.iloc[0, 0].latest_diagonal)
    answer = answer.incremental_.incr_to_cum().values[0, 0, :, -1]
    check = np.array([3483., 4007.84795031, 4654.36196862, 5492.00685523,
                      6198.10197128, 7152.82539296])
    assert_allclose(answer, check, atol=1e-5)
Esempio n. 3
0
def test_basic_transform(raa):
    cl.Development().fit_transform(raa)
    cl.ClarkLDF().fit_transform(raa)
    cl.TailClark().fit_transform(raa)
    cl.TailBondy().fit_transform(raa)
    cl.TailConstant().fit_transform(raa)
    cl.TailCurve().fit_transform(raa)
    cl.BootstrapODPSample().fit_transform(raa)
    cl.IncrementalAdditive().fit_transform(raa,
                                           sample_weight=raa.latest_diagonal)
def test_basic_transform():
    tri = cl.load_sample("raa")
    cl.Development().fit_transform(tri)
    cl.ClarkLDF().fit_transform(tri)
    cl.TailClark().fit_transform(tri)
    cl.TailBondy().fit_transform(tri)
    cl.TailConstant().fit_transform(tri)
    cl.TailCurve().fit_transform(tri)
    cl.BootstrapODPSample().fit_transform(tri)
    cl.IncrementalAdditive().fit_transform(tri,
                                           sample_weight=tri.latest_diagonal)
Esempio n. 5
0
def test_schmidt():
    tri = cl.load_sample("ia_sample")
    xp = np if tri.array_backend == "sparse" else tri.get_array_module()
    ia = cl.IncrementalAdditive()
    answer = ia.fit_transform(tri.iloc[0, 0],
                              sample_weight=tri.iloc[0, 1].latest_diagonal)
    answer = answer.incremental_.incr_to_cum().values[0, 0, :, -1]
    check = xp.array([
        3483.0,
        4007.84795031,
        4654.36196862,
        5492.00685523,
        6198.10197128,
        7152.82539296,
    ])
    assert xp.allclose(answer, check, atol=1e-5)