Skip to main content
Generated from the package’s Python API. Small, inspectable statistical models with explicit actuarial meanings. 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

A Poisson frequency or Gamma severity GLM whose predictors are categorical rating factors, such as driver age band and territory. Each factor’s fitted coefficients, exponentiated, are its relativities against a base level. A Poisson model reads one row per risk: 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

Whether the model has been fitted.

FactorModel.relativities

One row per factor level: 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

The fitted value at every factor’s base level and an offset of 1: claim frequency per unit of exposure for Poisson, average claim amount for Gamma.

FactorModel.summary

Fit statistics: dispersion (1 for Poisson; the claim-level Pearson estimate for Gamma), cells and rows.

FactorModel.table

One factor’s relativities as exact 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

Fit the model to 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

A Poisson frequency or Gamma severity GLM with a fixed log link. 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

Whether the model has fitted parameters.

LossModel.metadata

What the model is and what its predictions mean: configuration, link, prediction meaning, uncertainty and fit.

LossModel.input_schema

The JSON Schema of one prediction input: each feature, and the exposure.

LossModel.output_schema

The JSON Schema of one prediction: the conditional expected value, in unit.

LossModel.coefficients

The fitted coefficients by name, intercept first.

LossModel.fit

Fit unweighted observations; exposure is an offset, and every observation weighs the same. Missing/invalid observations fail fitting rather than silently changing the training population. Gamma dispersion is the Pearson estimate.

LossModel.call

Predict every input, keeping its ID; a bad input is prediction_failed.

LossModel.save

Save parameters and configuration as plain JSON data, free of executable code.

LossModel.load

Load a local JSON artifact from a file path.

LossResult

Predicted means and conditional distributions, with every input retained.

LossResult.distributions

Each output’s conditional distribution, by output name.

ConditionalDistribution

One distribution per successfully predicted record, aligned by identity. Poisson values describe counts over each record’s exposure. Gamma values describe a positive individual severity, one claim at a time.

ConditionalDistribution.mean

Each predicted record’s conditional mean, by identity.

ConditionalDistribution.quantile

Return outcome quantiles of each record’s distribution, as opposed to confidence limits for the fitted mean.

ConditionalDistribution.cdf

Return P(outcome <= value) for every predicted record.

ConditionalDistribution.survival

Return P(outcome > value), retaining accuracy in the upper tail.

ConditionalDistribution.sample

Return independent conditional draws; tuple position is the draw ID. Independence is a sampling convention, separate from any estimated portfolio dependence. Seeds reproduce draws for the same ordered inputs and numerical-library versions. Draws are simulated values, separate from the observed records.

evaluate_loss

Evaluate against caller-selected holdout data; the model keeps its fitted parameters.

LossEvaluationReport

Holdout diagnostics for one loss model, from 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.

LossEvaluationReport.summary

The report as a plain dict, with actual-to-expected, the weighting and the metric denominator spelled out.