Skip to main content
Package a prepare function, its schema and its examples with a rater, so one bundle carries the whole program. This page starts from the source of effective://example-ca-ppa. To release a guideline, or a rater on its own, for underwriting on Effective, export it with rslc export instead: Programs on Effective shows the steps. Install Relativities and set your API key before running this page.
Program.download saves the program’s source: the rater’s RSL and tables, and the program/ folder. Bundles and exact rating describes how a bundle carries and verifies its program.

Lay out the program folder

Put the program module, its helpers and the examples in one folder. The example program’s folder has this layout:
  • Import each helper relatively, as from .record import incidents.
  • In program.py, define prepare(book), which returns the rater’s inputs for each submission.
  • Also define SCHEMA, such as SCHEMA = ppa.SCHEMA. Use with_columns to declare a column of your own that prepare reads.
  • Put an example book in examples/book, in the Book.read_csv layout.

Name item result columns

Put an optional outcome-columns.json beside the program module to give stable names to the columns from program.rate(book, by="vehicles"). Each path starts with the rater’s list field, followed by the result key or keys inside an item. This example labels the total result inside each item of vehicles:
A path to an object applies the name as a prefix. For example, naming the premium object vehicle_premium gives its collision result the column vehicle_premium.collision. Other columns use their usual names. Packing checks that each path exists and its label is unambiguous. Rating by a table also checks the labels against that table’s ID columns. The JSON rating outputs retain their keys.

Write the expected outcomes

Write one row per example submission in expected.csv.
  1. Write the submission_id and status columns.
  2. Add the rater’s outcome columns that you want to check, such as premium.
  3. For a submission that stays unrated, leave its outcome cells empty.

Pack the program

Call Program.pack with the rater, the folder and a new .zip path.
  • By default, prepare and SCHEMA come from program.py, and the examples come from the examples folder.
  • To name other objects, pass prepare= and schema= as "module:name", such as "rules:prepare".
  • To choose the result columns, name a read function the same way, such as read="program:read". Set read.outcome_columns = ("premium", "fees") in the program file to retain those columns in the given order when the book is empty or every submission fails. Return every declared name for each successful call, using None for a missing value. A different set of names gives the submission a read_failed status. Omit the declaration to discover column names from the returned mappings.
Program.pack writes the bundle, loads it and checks its examples. The bundle gets a new bundle_id, and the rater’s own ID stays as engine_id. Each check rates every example, so the 100,000-policy example book takes the time of a full rating.

Load the program

To load a packaged program, call Program.load with a Path or a catalog ID.
Program.load takes revision= and local_files_only= as Rater.load does. It reads the example book while it loads, behind a progress bar (progress=False hides it), so program.example_book is ready at once. Rate it with program.rate(program.example_book).

Check the examples

Call program.check() to rate the examples again.
The table puts each expected value beside the rated one. Numbers match within half a cent. A mismatch raises CheckError, and its comparison holds the table.

Carry the program to a rebuilt rater

To move the program to a rater rebuilt from an edited filing, call program.with_rater. This rebuilt rater has a collision base rate of 1,600 in place of 1,519:
S000003 keeps its premium, because its vehicles carry liability and comprehensive coverages only.Rater.build compiles the folder’s RSL and tables into a new rater, and rebuilt.rater.save("my-ca-ppa-rater.zip") keeps its bundle. with_rater keeps the expected outcomes, so check shows each premium the new rater changes. Validate each change independently against the intended rate change.To accept the new premiums as the program’s expectations, pass rebaseline=True:
rebaseline=True checks that each example keeps its status, and raises CheckError with the submission ID for a changed status. Validate a program describes the evidence to keep for new expectations.

Next step

Validate a program before comparing its premiums with other programs. The rater in a program is written in RSL. Write your first rater builds one from a rating manual.