DevelopmentML help #534
Unanswered
Kish150898
asked this question in
Q&A
Replies: 1 comment
-
I also haven't been able to get DevelopmentML to work. I get the error: ValueError: could not convert string to float: 'Total' |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to implement a basic poisson regression using the DevelopmentML function on summy dummy data. Please can you point out any errors :) I am getting an error message " DevelopmentML' object has no attribute 'average" when trying to fit the model.
data = {
'Accident Year': [2020, 2020, 2020, 2020, 2020, 2021, 2021, 2021, 2021, 2022, 2022, 2022, 2023, 2023, 2024],
'Development Year': [2020, 2021, 2022, 2023, 2024, 2021, 2022, 2023, 2024, 2022, 2023, 2024, 2023, 2024, 2024],
'Paid': [1000, 300, 200, 50, 20, 3500, 800, 500, 100, 5000, 1000, 300, 8000, 2000, 9000]
}
df = pd.DataFrame(data)
Remove any non-numeric columns or rows
df = df.apply(pd.to_numeric, errors='coerce')
df = df.dropna()
Convert the DataFrame to a Triangle with incremental data
triangle = cl.Triangle(df, origin='Accident Year', development='Development Year', columns=['Paid'], cumulative=False)
Initialize the DevelopmentML model with a Poisson Regressor
model = DevelopmentML(
estimator_ml=PoissonRegressor(),
y_ml='Paid',
autoregressive=[('Paid', -1, 'Paid'), ('Paid', -2, 'Paid')],
fit_incrementals=True
)
Fit the model to the triangle data
model.fit(triangle)
Get the estimated loss development patterns
ldf = model.ldf_
Display the estimated patterns
print(ldf)
Beta Was this translation helpful? Give feedback.
All reactions