diff --git a/chainladder/core/common.py b/chainladder/core/common.py index 77f84d51..5b0dae75 100644 --- a/chainladder/core/common.py +++ b/chainladder/core/common.py @@ -174,6 +174,17 @@ def pipe(self, func, *args, **kwargs): >>> import chainladder as cl >>> raa = cl.load_sample('raa') >>> raa.pipe(lambda tri: tri.loc[..., 48:]) + 48 60 72 84 96 108 120 + 1981 11805.0 13539.0 16181.0 18009.0 18608.0 18662.0 18834.0 + 1982 10666.0 13782.0 15599.0 15496.0 16169.0 16704.0 NaN + 1983 16141.0 18735.0 22214.0 22863.0 23466.0 NaN NaN + 1984 21266.0 23425.0 26083.0 27067.0 NaN NaN NaN + 1985 22169.0 25955.0 26180.0 NaN NaN NaN NaN + 1986 12935.0 15852.0 NaN NaN NaN NaN NaN + 1987 12314.0 NaN NaN NaN NaN NaN NaN + 1988 NaN NaN NaN NaN NaN NaN NaN + 1989 NaN NaN NaN NaN NaN NaN NaN + 1990 NaN NaN NaN NaN NaN NaN NaN """ return func(self, *args, **kwargs) diff --git a/chainladder/development/clark.py b/chainladder/development/clark.py index 6a39e3ad..413e5420 100644 --- a/chainladder/development/clark.py +++ b/chainladder/development/clark.py @@ -134,29 +134,29 @@ class ClarkLDF(DevelopmentBase): clrd = cl.load_sample("clrd")[["CumPaidLoss"]] print(len(clrd.index)) m = cl.ClarkLDF(groupby="LOB").fit(clrd) - print(m.omega_.round(3)) - print(m.theta_.round(3)) + print(m.omega_.round(2)) + print(m.theta_.round(2)) .. testoutput:: :options: +NORMALIZE_WHITESPACE 775 CumPaidLoss - LOB - comauto 1.082 - medmal 1.889 - othliab 1.468 - ppauto 1.149 - prodliab 1.441 - wkcomp 1.107 + LOB + comauto 1.08 + medmal 1.89 + othliab 1.47 + ppauto 1.15 + prodliab 1.44 + wkcomp 1.11 CumPaidLoss - LOB - comauto 20.481 - medmal 35.128 - othliab 37.745 - ppauto 10.023 - prodliab 64.352 - wkcomp 20.111 + LOB + comauto 20.48 + medmal 35.13 + othliab 37.75 + ppauto 10.02 + prodliab 64.35 + wkcomp 20.11 """ diff --git a/chainladder/methods/benktander.py b/chainladder/methods/benktander.py index a83536dd..bcf84390 100644 --- a/chainladder/methods/benktander.py +++ b/chainladder/methods/benktander.py @@ -52,7 +52,6 @@ class Benktander(MethodBase): .. testcode:: xyz = cl.load_sample("xyz") - ibnr = cl.Benktander().fit(X=xyz["Paid"], sample_weight=xyz["Premium"].latest_diagonal).ibnr_ print(ibnr) @@ -76,7 +75,6 @@ class Benktander(MethodBase): .. testcode:: xyz = cl.load_sample("xyz") - bk_ibnr = ( cl.Benktander(n_iters=1) .fit(X=xyz["Paid"], sample_weight=xyz["Premium"].latest_diagonal) @@ -109,7 +107,6 @@ class Benktander(MethodBase): .. testcode:: xyz = cl.load_sample("xyz") - bk_ibnr = cl.Benktander(n_iters=1000).fit(X=xyz["Paid"], sample_weight=xyz["Premium"].latest_diagonal).ibnr_ cl_ibnr = cl.Chainladder().fit(xyz["Paid"]).ibnr_ print(bk_ibnr - cl_ibnr) @@ -165,7 +162,6 @@ def fit(self, X, y=None, sample_weight=None): .. testcode:: xyz = cl.load_sample("xyz") - ultimate = ( cl.Benktander(apriori=1, n_iters=2) .fit(X=xyz["Paid"], sample_weight=xyz["Premium"].latest_diagonal) @@ -218,6 +214,7 @@ def predict(self, X, sample_weight=None): current Triangle and a refreshed apriori. .. testsetup:: + import chainladder as cl .. testcode:: @@ -229,8 +226,8 @@ def predict(self, X, sample_weight=None): model = cl.Benktander(apriori=1.0, n_iters=2).fit( tr_prior, sample_weight=apriori_prior ) - - print(model.predict(tr, sample_weight=apriori).ultimate_) + ultimate = model.predict(tr, sample_weight=apriori).ultimate_ + print(ultimate) .. testoutput:: diff --git a/chainladder/methods/bornferg.py b/chainladder/methods/bornferg.py index 695a6f49..ee968b2e 100644 --- a/chainladder/methods/bornferg.py +++ b/chainladder/methods/bornferg.py @@ -53,7 +53,6 @@ class BornhuetterFerguson(Benktander): raa = cl.load_sample("raa") premium = raa.latest_diagonal * 0 + 40_000 # zero out and add 40,000 to each origin - ibnr = cl.BornhuetterFerguson(apriori=0.7).fit(X=raa, sample_weight=premium).ibnr_ print(ibnr) @@ -77,7 +76,6 @@ class BornhuetterFerguson(Benktander): raa = cl.load_sample("raa") premium = raa.latest_diagonal * 0 + 40_000 * 0.7 # premium is modified by 70% - ibnr = cl.BornhuetterFerguson().fit(X=raa, sample_weight=premium).ibnr_ print(ibnr) @@ -123,13 +121,15 @@ def fit(self, X, y=None, sample_weight=None): Fit returns the estimator itself, with ``ultimate_`` populated. .. testsetup:: + import chainladder as cl .. testcode:: tr = cl.load_sample('ukmotor') apriori = cl.Chainladder().fit(tr).ultimate_ * 0 + 14000 - print(cl.BornhuetterFerguson(apriori=1.0).fit(tr, sample_weight=apriori)) + model = cl.BornhuetterFerguson(apriori=1.0).fit(tr, sample_weight=apriori) + print(model) .. testoutput:: @@ -160,6 +160,7 @@ def predict(self, X, sample_weight=None): current Triangle and a refreshed apriori. .. testsetup:: + import chainladder as cl .. testcode:: @@ -171,10 +172,10 @@ def predict(self, X, sample_weight=None): model = cl.BornhuetterFerguson(apriori=1.0).fit( tr_prior, sample_weight=apriori_prior ) + ultimate = model.predict(tr, sample_weight=apriori).ultimate_ + print(ultimate) - print(model.predict(tr, sample_weight=apriori).ultimate_) - - .. testoutput + .. testoutput:: 2261 2007 12690.000000 diff --git a/chainladder/methods/capecod.py b/chainladder/methods/capecod.py index 4175e2ae..1470104d 100644 --- a/chainladder/methods/capecod.py +++ b/chainladder/methods/capecod.py @@ -218,7 +218,7 @@ def fit(self, X, y=None, sample_weight=None): exposure = cl.Chainladder().fit(tr).ultimate_ * 0 + 20000 print(cl.CapeCod(trend=0.05).fit(tr, sample_weight=exposure)) - .. testoutput: + .. testoutput:: CapeCod(trend=0.05) """ diff --git a/chainladder/methods/chainladder.py b/chainladder/methods/chainladder.py index 893933f3..2ab4ca61 100644 --- a/chainladder/methods/chainladder.py +++ b/chainladder/methods/chainladder.py @@ -124,12 +124,13 @@ def fit(self, X, y=None, sample_weight=None): attribute access. .. testsetup:: + import chainladder as cl .. testcode:: tr = cl.load_sample('ukmotor') - cl.Chainladder().fit(tr) + print(cl.Chainladder().fit(tr)) .. testoutput::