Skip to main content
In this tutorial, you rate six households with a synthetic carrier, explain one premium, and add a second carrier. You finish with a matched premium exhibit and explicit rating exceptions.

1. Read the book

Read the synthetic book from its CSV files: Install Relativities and download the example data before running this page.
The book holds facts as reported, such as birth dates. Each submission is one household’s request to price.

2. Write prepare

Carrier A’s rater takes each driver’s age, and each vehicle’s mileage and collision deductible. Write a prepare function that reads the whole book and returns each submission’s rater input, keyed by submission_id:
prepare is plain pandas. Its input for each submission has the shape of the rater’s inputs.

3. Rate the book

Pair the rater with prepare in a program, and rate the book. schema is the book the program accepts:
Each submission keeps its row. Carrier A’s premium is for a six-month term. S4’s vehicle exceeds the rater’s mileage limit, so S4 has the status invalid_inputs and the premium NaN. carrier_a.schema lists each table and column the program accepts. Read the drivers’ dates:
A program checks each book against its schema before prepare runs, and gives prepare only the schema’s columns.

4. Explain a premium

Explain S2’s premium of $825:
The input rows show what the rater received. The calculation rows show each step to the premium. The 19-year-old driver brings a young driver factor of 1.25. explanation.json_in is the input that prepare built, and explanation.book holds S2’s facts.

5. Add a second carrier

Carrier B’s rater takes each driver’s years licensed, each vehicle’s miles, and a comprehensive flag. Write its prepare, and rate the book with both carriers in a market:
The market adds a program column. Each carrier’s outcome keeps the name its rater gives it: premium for six months from carrier A, and annual_premium for twelve months from carrier B.

6. Compare on one basis

Select liability only, then annualize carrier A’s six-month premium for this illustrative comparison:
Carrier B has the lower premium on all three matched submissions. Three other submissions have at least one unrated program. Retain their statuses and reasons with the exhibit. A calculated premium is a rating result, and underwriting appetite needs its own evidence. For a market study, align limits, deductibles, fees, effective dates, and term conversion too. Compare carriers adds mapping checks and a segment summary with explicit population counts.

What you did

You prepared shared facts, wrote prepare for two raters, explained a premium, and compared a matched population. To go further: