Skip to main content
Each carrier’s rater defines its own input schema and premium outputs. A book stores driver and vehicle facts in a shared schema. A program pairs a rater with the Schema of the book it accepts and a prepare function that builds the rater’s inputs from that book.

The schema is the program’s shape

program.schema is a Schema, the same type as book.schema. It lists each table and column the program accepts, with its type and whether it is required. A line’s schema, such as ppa.SCHEMA, accepts the line’s core columns. To read a column of your own, declare it with with_columns:
Read the schema in pandas with program.schema.to_pandas(), or print it. Relativities includes these line schemas: A line’s core columns are facts, such as year_built or liquor_sales. A carrier’s own selectors, such as its class code, tier or territory, are columns the program declares with with_columns. The gl tables are the liability part of the bop tables, so a general liability book is also a businessowners book.

Household exposures

The homeowners schema includes an optional exposures table, keyed by submission_id and exposure_id. Each row describes one household exposure, such as a watercraft or an incidental occupancy. Watercraft facts include propulsion, hull length in whole feet and engine horsepower. Optional insured_id, dwelling_id and premises_id references name rows in the same submission. Each reference has type id and uses the target row’s identifier. An exposure can belong to the household through its submission alone. The dwelling reference associates the exposure with a dwelling; the premises reference identifies its location at another premises. The referenced other_premises.kind identifies an other structure, additional residence or care facility. Coverage purchases, limits and carrier classifications stay in coverage tables or program extensions. A program can extend exposure rows with its own columns through with_columns(exposures=...). Books that omit the table receive an empty exposures table. Existing programs with their own exposures declaration must match the core’s column types. Declare premises_id as Column("id"), or inherit that column from the core. Rebuild the program bundle with the updated declaration for ho/1.2.

Common protection requests and product choices

A homeowners Book can hold one common protection request and explicit options for several products. coverages holds the common request; coverage_options uses the same coverage terms and adds the product’s documented program_id. A matching option replaces the entire common row. Missing option terms stay missing. A percentage-only election therefore carries an empty dollar amount.
example-ca-ho is an illustrative product ID. Use each program’s documented ID; it selects an explicit request; the program derives its rating factors. Additional matching option rows add coverages. Options for other products stay in the original Book. A zero limit remains an explicit zero, and an option with blank terms remains a selection for the program to validate. The helper returns the selected rows. Each program validates filed limits, required coverages and whether it can offer the requested terms. The same pattern applies to deductibles and deductible_options, keyed by peril. ho.deductibles_for resolves whole-row product choices; each selected row supplies an amount or percentage. A product can therefore request a separate water deductible while retaining the same observed household Book.

Observations stay separate from qualification

HO1.2 also provides dated loss_payments, household residence_employees, system updates, solid-fuel appliances and organization memberships. Their references stay within the same submission. A features row’s columns describe the feature that row names, and verified verifies only that row. Dwelling-wide ember-zone facts, such as deck, five-foot and 30-foot clearance, sit on the ember_resistant_zone row; there False records an observed failure and empty means unknown. An employee row describes household work. An actual coverage row separately records an optional employee-coverage purchase. Membership active is observed at the rated effective date: false and unknown remain distinct, and simultaneous clubs have separate rows. aaa_memberships_complete declares the AAA club inventory. Other association inventories remain separate. Personal loss-history completeness and premises history are separate. Some facts are recorded at two resolutions or from two angles: equivalent bathrooms and bathroom rooms; measured tree-overhang percent and observed extent; a dwelling’s plumbing-renovation summary and its dated system_updates; a water_shutoff device and a detector’s own automatic_shutoff; and amount paid, net paid, incurred and individual payments. The HO1.2 column’s meaning states how the two relate and what agreement a Book must keep; an HO1.1 column’s meaning stays as released. The Book never fills one from the other; a program reads the column its filed rule names and decides what to do when only the counterpart is supplied. A dated payment keeps its observed date independently of carrier cutoffs. Total rental nights differ from short-stay nights. Both counts use observed nights; short-stay weeks retain their own unit. Licensed wildfire reports keep their actual model, score and provenance. An unacquired report remains unknown, distinct from observed zero and the vendor’s explicit no-result value (no_score for Verisk FireLine, vendor_no_hit for ZestyAI Z-FIRE). A vendor or model the line does not name yet is declared by the program with with_columns, using the naming convention in the relativities.ho reference, so that a later minor version can add the same columns without breaking it. A tier or factor a carrier assigns from a score is a program column, not a vendor fact. New core columns are optional schema vocabulary. A selected risk can still require a particular fact before its program can calculate a premium. Actual carrier decisions, qualified employment/affinity relationships and inseparable named packages remain declared, carrier-qualified program columns.

Pet health

A pet book’s group is the policyholder. One submission prices one owner’s pets together. One carrier writes a policy for each pet, and another puts every pet on one policy. Each pets row holds the pet’s facts: species, breed, sex, date of birth and enrollment date. It also holds the plan the owner chose: the product, deductible, reimbursement and annual limit. Coverages beyond accident and illness, such as wellness or dental illness, are coverages rows of the pet, with their own limits. reimbursement_percent is the insurer’s share of a covered bill after the deductible, such as 90. Carriers file this share two ways: Read the filing’s coinsurance table to tell them apart. The factor is 1 at the plan’s highest reimbursement, where the loss elimination ratio equals the insurer’s share. breed is the breed as the owner states it, and each carrier lists breeds in its own words, such as “Mixed (Large 51-110 Lbs.)” for a mixed breed. A program maps the book’s breed, mixed_breed and adult_weight to its carrier’s list. A breed the map lacks fails only its own submission: the rater refuses a breed outside its filed list. The book keeps carrier assignments out of the core. A breed group, a territory or a renewal experience level is derived by the rater from the filed tables. When a rater takes one as an input, the program declares it with with_columns:

Declared columns and later versions

A minor version of a line adds columns, tables and allowed values. It can add a core column with the name of a column that a program declares. The program still loads: with_columns keeps the line’s column when the declaration agrees with it. A declaration agrees when it has the same type, the same requirement, the same unit or an empty unit, and for an enum, values that the line’s column allows. The meaning can differ, because it is the program author’s own words. An enum declared with fewer values keeps only those values. A submission with any other value is invalid_book, and prepare reads only the submissions that remain. A declaration that disagrees raises ValueError, and the message names both specifications. with_tables uses the same rule for a table with the same name, key and requirement.

prepare holds each carrier-specific rule

prepare is a function from a book to the rater’s inputs. It returns Inputs: one table for each field of rater.inputs, such as Inputs(drivers=drivers, vehicles=vehicles). Each table has a submission_id column, and the program nests its rows into each submission’s input:

What a program guarantees

  • The schema is enforced. rate and explain check the book against the program’s schema. A missing required column raises BookError before prepare runs. A value of the wrong type, or outside its column’s range, fails its submission as invalid_book, and the rest rate.
  • The schema is all prepare reads. prepare gets a copy of the book with only the schema’s tables and columns. A column outside the schema raises KeyError in prepare, so program.schema lists every column the program can depend on.
  • prepare builds one input for every submission. It derives and renames values in one vectorized call per chunk, and it keeps a blank fact blank. Document carrier-specific defaults and assumptions in the preparation code. A submission it leaves out, or an exception it raises, is a bug in the program, so rate raises.
  • prepare asks for an answer as data. Some submissions need an answer before they rate, such as which trim a vehicle is. prepare fails that submission with a Need in Inputs(failures=...). The need names the book column for the answer, the row, and any allowed options. rate returns it as mapping_failed with the code NEEDS_INPUT, and lists each need in the needs column. A need’s column belongs to the program’s schema, so prepare reads the answer on the next rate.
  • prepare’s columns fit the rater’s input types. Before it rates a chunk, rate checks that each column of the Inputs names an input in rater.inputs. It also checks that each required input has a column, and that each column’s type fits its input. A mismatch, such as text for an int, is a bug in the program: rate raises TypeError and names each column.
  • The rater fails each unratable submission alone. The rater checks every input against rater.inputs before it rates any. A blank required field or an unfiled code gets the status invalid_inputs, with the field’s path in the reason. A carrier’s eligibility rule, such as the limits it files, lives in the rater and gets refused, with the carrier’s code. The check stops before the calculation, so the other rows rate at full speed.
  • Explain matches rate. explain runs prepare on the chunk that rate gives it, so its input rows are the exact input rated. Its keys are the keys of rate, so its table merges with the book and with the rows of rate.
Keep unrated rows visible in your analysis. explain shows the input that the rater rejected, next to the book’s rows on the same keys.

Result columns carry the rater’s own names

rate returns the rater’s RatingOutcomes as columns, with the names the rater gives them. The rater defines what it returns, so the result shows exactly that. A total is the carrier’s own total, and a premium carries the carrier’s own term. A column takes the outcome’s name, and explain takes the name of the calculation the outcome points to. So premium: Policy.policy_premium is the column premium in rate and the step policy_premium in explain. A map outcome has a column per key, and with by, so does an outcome of each item, such as vehicle_premium.liability. In a market, two programs share a column when their raters give an outcome the same name. A six-month premium and a twelve-month annual_premium stay in separate columns. A comparison basis, such as an annual premium, is your choice. State it once per program, in its read. read(inputs, outputs) returns the program’s columns for one result, such as {"annual_premium": outputs["premium"] * 2}. outputs holds the root record’s calculations by their own names, as explain names them. Programs whose read returns the same name share a column, so a market’s table is on one basis. program.with_read gives a loaded program another read.

Each program in a market keeps its own contract

A market holds named programs, and each program keeps its own schema and rater inputs. A merged schema would lose which program needs each column, so read each contract by program:
Each row names its program. Concatenate each program.schema.to_pandas() the same way, for one row per book column each program accepts. market.rate checks the book against each program’s schema before that program’s prepare runs.

Each layer adds its key

Analysis code for one program works on a market’s table too: it groups by one more column. rate(data, by="vehicles") keys each row by a table of the book too, such as vehicle_id: one row per vehicle, with its submission’s status and the rater’s outcomes for that vehicle. by takes any table of the book’s schema with one row per item of a submission, so the names come from the schema alone. A program links each item through the IDs in its Inputs, whatever the rater calls the list. An item may also carry other ID columns its own table holds, such as an incident’s driver_id. A program whose rater returns outcomes per submission alone has NaN there. A study whose scenarios set one parameter to several values adds a column for it after its keys, such as miles for [at(miles=m) for m in range(0, 32_001, 500)].

One rating path

program.rate and market.rate use the same native engine as rater.rate. The unit of work is one program and one chunk of up to 10,000 submissions from one version of the book. prepare returns the chunk’s Inputs tables, and their columns go to Rust in one call. Rust builds each submission’s input, checks it and rates it on every core, and Python’s other threads run meanwhile. Each input is exactly the one its JSON would be, so the rows are the same either way. A study passes each input’s fingerprint back in, and Rust skips a submission whose input repeats an earlier version’s. Units run on two threads, so one chunk’s prepare runs while another rates, and a study builds one version at a time, so memory holds a few chunks, plus the result rows.Each input depends only on its own submission’s rows, so a chunk gives the same rows as the whole book. explain runs prepare on the chunk that holds the submission, then rates the one submission again with each calculation kept. Rating is deterministic, so the explanation matches the rated row. market.explain gives each program’s explanation side by side.

Mapping quality is part of rating quality

A correctly implemented algorithm still needs the right inputs. Vehicle symbols, territory assignments, discounts, and coverage selections can change a comparison materially. explain exposes the inputs passed to RSL and its calculations. Review the Python prepare function to establish each mapping’s source and assumptions. Use Validate a program to reconcile independent cases before analyzing the full book.