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:
program.schema.to_pandas(), or print it.
prepare holds each carrier-specific rule
prepare is a function from a book to {submission_id: json_in}. Each json_in has the shape
of rater.inputs, and it depends only on that submission’s rows. rate gives prepare the book
in chunks, and a failing submission is left out of the book, so this rule keeps each input the
same however the book is split. Relativities converts its values to JSON: dates become ISO text, numpy
numbers become Python numbers, a missing field is left out, and a missing list element stays as None.
The book stays the same for each carrier, and a change to one carrier touches its own prepare.
For a carrier’s own estimate of an empty fact, write a new prepare that fills the fact and calls
the old one. The book keeps the fact as reported, so one carrier’s estimate stays out of another
carrier’s input.
What a program guarantees
- The schema is enforced.
rateandexplaincheck the book against the program’s schema. A missing required column, or a value of the wrong type, raisesBookErrorbeforeprepareruns. - The schema is all
preparereads.preparegets a copy of the book with only the schema’s tables and columns. A column outside the schema raisesKeyErrorinprepare, soprogram.schemalists every column the program can depend on. - One bad submission fails only itself. When
prepareraises, Relativities halves the book until it finds each submission thatpreparefails on alone. Those rows get the statusmapping_failedand the reason codePREPARE_FAILED, with the function’s name and the exception as the reason.preparethen runs again on the rest of the book, and the other rows rate. A clean book runsprepareonce. - A submission that
prepareleaves out stays in the results. Its status ismapping_failed, with the reason codeNOT_PREPARED. - Explain matches rate.
explainrunsprepareon the chunk thatrategives it, so itsjson_inis the exact input rated and itsrowis the rowrategives. Itsbookholds the submission’s facts, with the schema’s columns.
prepare logic.
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.
In a market, two programs share a column when their raters give an outcome the same name. Carrier
A’s six-month premium and carrier B’s twelve-month annual_premium stay in separate columns.
The choice of a comparison basis, such as an annual premium, stays with you, in pandas.
Each layer adds its key
Analysis code for one program works on a market’s table too: it groups by one more column.
One rating path
program.rate and market.rate use the same path as rater.rate: parallel native batches. The
unit of work is one program and one chunk of up to 10,000 submissions from one version of the
book. Units run on two threads, 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.