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 0.1.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 0.1.0
File Size Uploaded Provenance Actions
open_rating_engine-0.1.0.tar.gz 138.5 kB With provenance Details for open_rating_engine-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 236.3 kB

Release files / open_rating_engine-0.1.0.tar.gz

Download URL open_rating_engine-0.1.0.tar.gz
Size 138.5 kB
Tags Source
SHA-256 checksum
How to use checksums
15a1e4c0f0725e411407fd8522071e2fca30946a37c4350b451589d9515aaa81
BLAKE2b-256 checksum
How to use checksums
8e7b5460e8b3b27a957f80d74354b8308d10e2f86ea37690cba73998f82dbf7c
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 Oct 26, 2026.

Transparency log

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

Download URL open_rating_engine-0.1.0-py3-none-any.whl
Size 97.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c1cbd072e66dca49caf0caa3579b5a0fc1454780b96a2a16cd9a2644edc94b9
BLAKE2b-256 checksum
How to use checksums
52cd67095f7c9ce1cf8995e7921043e8006ea01207ad72c9a31ad0caa1fe7123
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 Oct 26, 2026.

Transparency log

Security for open-rating-engine 0.1.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-0.1.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 Oct 26, 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