Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] #411

Closed
henrydingliu opened this issue Dec 22, 2022 · 1 comment · Fixed by #433
Closed

[BUG] #411

henrydingliu opened this issue Dec 22, 2022 · 1 comment · Fixed by #433
Labels

Comments

@henrydingliu
Copy link
Collaborator

Describe the bug
applying a cl estimator to another triangle doesn't always work

To Reproduce

import chainladder as cl
clrd_total = cl.load_sample('clrd').sum()[["CumPaidLoss"]]
clrd = cl.load_sample('clrd').groupby("LOB").sum()[["CumPaidLoss"]]
est = cl.Chainladder().fit(clrd_total)
try:
    est_other = est.predict(clrd[clrd["LOB"]=="comauto"])
except:
    print("this doesn't work")
est = cl.Chainladder().fit(clrd[clrd["LOB"]=="comauto"])
est_other = est.predict(clrd_total)
print(est_other.ultimate_)
print("but this works")

Expected behavior
the code inside the try should work

Desktop (please complete the following information):

  • Numpy Version 1.21.6
  • Pandas Version 1.4.4
  • Chainladder Version 0.8.14
@jbogaardt
Copy link
Collaborator

Thanks for finding. This is a case where broadcasting should take precendence over index alignment. That is
if X.shape[0] == 1 or est.cdf_.shape[0] == 1, then these should multiply together like numpy arrays. Basic arithmetic works:

ultimate = (
    clrd[clrd["LOB"]=="comauto"] * 
    est.cdf_.iloc[..., :-1]
).latest_diagonal

So I think there is an issue in intersection method of the Chainladder model that is not allowing broadcasting when it should.

jbogaardt added a commit that referenced this issue May 28, 2023
@jbogaardt jbogaardt linked a pull request May 28, 2023 that will close this issue
jbogaardt added a commit that referenced this issue May 28, 2023
kennethshsu pushed a commit that referenced this issue Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants