LossModel: Poisson models predict counts, optionally over a supplied
exposure. Gamma models predict positive individual claim severities. Both use a
log link and numeric features. Both predict individual records; aggregate loss
and parameter uncertainty are outside their scope.
FactorModel fits the same two families over categorical rating factors and
reports each level’s relativity, ready to become a rater’s table.
Fit relativities
Fit and predict
Distributions
Evaluate predictions
FactorModel
target is its claim count and exposure its
earned exposure. A Gamma model reads one row per claim: target is its amount. Rows are
summed into one cell per combination of levels before fitting, which gives the same
estimates as fitting every row and keeps a large book fast.
offset names a column of positive multipliers held fixed in the fit, such as each
risk’s current relativity for the other factors, so the fitted relativities are relative
to it. base picks each factor’s base level; by default it is the level with the most
exposure (Poisson) or the most claims (Gamma), the populous base that CAS Monograph 5
recommends.
fit returns a new, fitted model. relativities lists every level with its
relativity, standard error and 95% interval; table gives one factor’s relativities as
exact Decimals, rounded, ready to merge into a rater’s table and pass to
Rater.with_tables.
FactorModel.fitted
FactorModel.relativities
factor, level, relativity, std_error (of
the log relativity), lower and upper (the 95% interval), weight (exposure
for Poisson, claims for Gamma), rows and base.
FactorModel.base_value
FactorModel.summary
dispersion (1 for Poisson; the claim-level Pearson estimate for
Gamma), cells and rows.
FactorModel.table
Decimals rounded half up to scale places.
Columns: the factor’s own name, holding each level, and column. The base level is
exactly 1. Levels keep the type they have in the data; a rater’s table keys are text,
so convert numeric levels with astype(str) before matching them to a rater table.
FactorModel.fit
data and return a new, fitted model.
Fitting stops with an error that names the problem for a missing column, a blank
factor or target, collinear factors, or a Poisson level with zero claims. Group such a
level with a neighboring level first.
LossModel
fit returns a new model. Configuration and fitted parameters are immutable.
Predictors are explicit numeric columns, used as given, with formulas and
learned preprocessing out of scope. Everything a prediction needs lives in
the persisted model.
LossModel.fitted
LossModel.metadata
LossModel.input_schema
LossModel.output_schema
unit.
LossModel.coefficients
intercept first.
LossModel.fit
LossModel.call
prediction_failed.
LossModel.save
LossModel.load
LossResult
LossResult.distributions
ConditionalDistribution
ConditionalDistribution.mean
ConditionalDistribution.quantile
ConditionalDistribution.cdf
ConditionalDistribution.survival
ConditionalDistribution.sample
evaluate_loss
LossEvaluationReport
evaluate_loss.
Totals, mean absolute error and mean deviance cover the records that could
be evaluated, unweighted. Every excluded record is in failures with its
reason.