How to manually overwrite the link ratios? #443
Replies: 2 comments 4 replies
-
Hi @contenrico. Neither the To achieve the functionality you're looking for, I could suggest doing the modification outside of an estimator and using For example: import chainladder as cl
import numpy as np
raa = cl.load_sample('raa')
# Modify link ratios however you want. Here I am naively limiting the low and high of my link ratios directly
limited_link_ratios = np.maximum(np.minimum(raa.link_ratio, 5), 1.0)
# Convert link ratios into a selected pattern stored as a dictionary of (age, ldf) pairs.
selected_patterns = dict(
zip(raa.development[:-1],
limited_link_ratios.mean().to_frame().iloc[0])
)
# Use DevelopmentConstant to leverage your custom patterns in a compliant way
pipe = cl.Pipeline([
('dev', cl.DevelopmentConstant(patterns=selected_patterns, style='ldf')),
('model', cl.Chainladder())]
)
# Fit a chainladder model to your selected patterns and explore its properties.
pipe.fit(raa).named_steps.model.ibnr_ |
Beta Was this translation helpful? Give feedback.
-
The |
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm trying to manually overwrite the link ratios calculated through
triangle.link_ratio
.As
triangle.link_ratio
is also a Triangle object, I'm guessing I can use.loc[]
to substitute specific link ratios with my manual inputs. However, I can't find a way to maintain these all the down the pipeline.For example, when I subsequently use
cl.Development().fit(triangle)
, it goes back to using the original link ratios. However, I'd like to be able to use all the functionalities ofcl.Development
andcl.Chainladder()
with my modified link ratios. Is it possible to do that?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions