Skip to main content

open-rating-engine

An insurance/banking rating engine for Python. You describe a pricing algorithm as a set of typed layers; the engine builds a dependency graph (DAG) from them and scores policies through it. It also ships price optimisers that run on top of a pipeline.

A pipeline is an MLflow PythonModel, so you log, version, load and serve it with standard MLflow tooling.

Install

pip install open-rating-engine          # core: pipeline, layers, optimisers
pip install "open-rating-engine[all]"   # plus every optional extra
Extra Adds Needed for
h2o h2o, jpype1 H2OScoringParameter (H2O MOJO scoring)
onnx onnxruntime OnnxScoring
viz plotly, networkx PyfuncPricingPipeline.plot_dag()
notebook ipywidgets optimiser progress bars in Jupyter

Optional dependencies are imported lazily, so import open_rating_engine works on a core-only install.

Imports

The headline names (the pipeline, every layer class, the layer exceptions and apply_aging) are available from the top-level package. Everything else lives in its subpackage:

from open_rating_engine import PyfuncPricingPipeline, RatingTablesLayer, apply_aging
from open_rating_engine.optimization import PriceOptimizerRatingFactor
from open_rating_engine.rating_engine.binning import thermometer_column_names

Package __init__ modules load their names on first use, so import open_rating_engine is near-instant. You pay for mlflow only when you touch the pipeline or a layer. Each module's __all__ defines its public API.

Rating engine

PyfuncPricingPipeline (open_rating_engine.rating_engine.pricing_pipeline):

  • add_parameter() / remove_parameter() register and remove layers.
  • Layers are topologically sorted, and cycles are reported. Independent column calculations run in parallel waves. Structural layers (joins, drops, renames, aggregations) run in sequence so that tables stay consistent.
  • predict(context, model_input) is the MLflow-compatible scoring entry point.
  • load_context(context) expects every artifact in context.artifacts to be a local file path. The engine fetches nothing remote, so download artifacts from blob storage or a model registry before building the context.
  • profile_predict() returns how long each layer took. plot_dag() draws the graph.

Pipeline state is a dict of named DataFrames. Each layer declares what it reads (depends_on) and what it writes, and the pipeline builds the DAG from those declarations.

Layer types (open_rating_engine.rating_engine.pricing_layers), all extending BasePricingLayer:

Layer Purpose
SourceColumn Declares an input column supplied in the scoring payload
ColumnCalculation Computes a new column from an expression string (restricted builtins) or a callable
TableTransform Creates or replaces a table with a callable
TableAggregation Group-by with named aggregations, e.g. {"total": ("cost", "sum")}
TableJoin Merges two tables; the key names can differ on each side
RenameColumns / DropColumns Column-level changes
TableDrop Removes an intermediate table from the pipeline state
RatingTablesLayer Looks up rating factors from several tables and multiplies them together
GlmScoring Scores a GLM or other additive model in closed form, with no JVM
H2OScoringParameter Scores an H2O MOJO model (regression / binomial / multinomial)
OnnxScoring Scores an ONNX model
CustomLayer Runs any callable that doesn't fit a typed layer

open_rating_engine.rating_engine.binning holds the thermometer (cumulative) encoding. Training and scoring both use it, so they produce identical columns.

Price optimisation

open_rating_engine.optimization:

Optimiser Decision
PriceOptimizerIndividual A multiplier for each policy, for a single period
PriceOptimizerRatingFactor A multiplier for each rating-factor level, for a single period
PriceOptimizerIndividualMultiPeriod A lifetime multiplier for each policy, chosen against multi-period NPV
PriceOptimizerRatingFactorMultiPeriod A rating-factor overlay, chosen by forward-simulating the horizon

Helpers: simulate_adjustment_grid, make_demand_emulation, make_log_multiplier_penalty and make_log_multiplier_regularizer.

Multi-period optimisers age the book each period with open_rating_engine.data_processing.data_aging.apply_aging.

Development

pip install -e ".[all,test]"
pytest

License

Apache License 2.0. See LICENSE.

Metadata

Release files for open-rating-engine 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for open-rating-engine 2.0.0
File Size Uploaded Provenance Actions
open_rating_engine-2.0.0.tar.gz 161.8 kB With provenance Details for open_rating_engine-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for open-rating-engine 2.0.0
File Interpreter ABI Platform Actions
open_rating_engine-2.0.0-py3-none-any.whl Python 3 none any Details for open_rating_engine-2.0.0-py3-none-any.whl

Total release size: 279.2 kB

Release files / open_rating_engine-2.0.0.tar.gz

Download URL open_rating_engine-2.0.0.tar.gz
Size 161.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a33055f8e20465e67cb67d59e698fea18c6edec7072a8d509a137b1c8f204d46
BLAKE2b-256 checksum
How to use checksums
8e8330a12499153831f0fb8749ea94333e02888cf15fb126075e99e4caf66904
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / open_rating_engine-2.0.0-py3-none-any.whl

Download URL open_rating_engine-2.0.0-py3-none-any.whl
Size 117.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
79babba217f17c39ae2335e372e2c399332c1ea035fd126052a5549053d36359
BLAKE2b-256 checksum
How to use checksums
713b0ad4a72c1891a749a343c96a37fdf42019c5c642a8a8985b02042cfd2adf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for open-rating-engine 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for open_rating_engine-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page