> ## Documentation Index
> Fetch the complete documentation index at: https://docs.canary.effectiveai.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Test a rater

> Check independently calculated premiums, rating boundaries, and refusal codes against a rater.

Use independent rating examples to check premium correctness. Compiler checks and packaged expectations provide separate evidence about the implementation.

## Load the example rater

```python theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
from relativities import Program, Rater

folder = Program.download("effective://example-ca-ppa", "example-ca-ppa/")
rater = Rater.load(folder)
```

To test a rater that you are writing, compile it from its source with `Rater.build("dwelling/rater.rsl")`.
[`Rater.build`](https://docs.canary.effectiveai.app/relativities/reference/relativities#rater-build) takes the `.rsl` file or its folder, and `Rater.load` takes a packaged bundle.

The example program is synthetic. The following expected annual premiums come from its rate tables and a hand calculation.
Expand **Example policy inputs** and copy the inputs before running the checks.

> [accordion] Example policy inputs
>
> Copy these inputs for a driver with 24 years licensed and one vehicle:
>
> ```python theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
> driver = {"number": 1, "years_licensed": 24, "marital_status": "single", "good_student": False, "financial_responsibility_filing": False, "incidents": []}
> vehicle = {"number": 1, "garaging_zip": "92683", "make_model": "HONDA/ODYSSEY", "vehicle_age": 7, "annual_mileage": 12000, "use": "commute", "rideshare": False, "anti_theft": "none", "bodily_injury_limit": "30/60", "property_damage_limit": "15", "combined_single_limit": False, "uninsured_motorist_property_damage": False, "collision_deductible_waiver": False, "roadside": False, "loan_gap": False, "custom_equipment_limit": 0}
> policy = {"Policy": {"multi_policy": False, "years_with_us": 0, "drivers": [driver], "vehicles": [vehicle]}}
> multi_policy = {"Policy": {**policy["Policy"], "multi_policy": True}}
>
> ```

## Compare independent premiums

| Step | Bodily injury | Property damage |
| - | - | - |
| Base rate | 550 | 358 |
| Territory `orange_ventura` | × 1.02 | × 1.02 |
| Liability symbol 1 | × 0.90 | × 0.92 |
| 24 years licensed | × 0.90 | × 0.90 |
| Limits 30/60 and 15 | × 0.80 | × 0.88 |
| Good Driver | × 0.8 | × 0.8 |
| Rounded to the dollar | 291 | 213 |
| With the multi-policy factor 0.9 | 262 | 192 |

Every other factor is 1. The annual premium is 504, or 454 with the multi-policy discount.

```python theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
cases = [(policy, 504), (multi_policy, 454)]
results = rater.rate([request for request, _ in cases]).to_pandas()
assert results["premium"].tolist() == [expected for _, expected in cases], results
```

The assertion checks both premiums against the independent expectations.

## Check boundaries and business rules

Add cases at both sides of rating bands, such as annual mileage 12,500 and 12,501.
Test each business rule with a request that breaks it, then compare the returned code:

```python theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
rideshare = {
    **policy,
    "Policy": {
        **policy["Policy"],
        "vehicles": [{**vehicle, "rideshare": True}],
    },
}
refused = rater.rate(rideshare).to_pandas()
assert refused["status"].item() == "refused"
assert refused["reason_code"].item() == "RIDESHARE"
```

Use `rater.explain(policy)` to inspect inputs, factors, and rounding when a result differs from its expectation.

## Check packaged expectations

```python theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
program = Program.load(folder)
comparison = program.check()
comparison["matches"].all()  # True
```

Packaged expectations detect changes to previously recorded results. Independent cases establish whether selected premiums follow the intended rating rules.

## Next step

[Validate a program](https://docs.canary.effectiveai.app/relativities/how-to/validate-a-program.md) before comparing real quotes or full books.
Record the rating inputs, effective dates, coverage terms, fees, and any unresolved differences.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.