Case study · Insurance pricing

K-means and GLMs: pricing 74 breeds that did not fit one tariff

Breed drives the risk of a pet policy, but 74 breeds are too many levels for a stable tariff. We grouped them by risk profile with K-means, found nine breeds priced below cost, and built frequency, severity and Tweedie GLMs on the groups.

The need

A pet insurer covering dogs and cats wanted a tariff that reflected risk without becoming unreadable. The portfolio held about 39,000 policy-years from 2018 to September 2022. Breed clearly mattered, but with 74 breeds many levels had too little exposure to support their own coefficient.

Grouping breeds by risk, not by name

Each breed was described by its claim frequency, average claim cost and pure premium, then grouped with K-means. Elbow and silhouette diagnostics supported three groups. Group A gathers 42 breeds and 85% of the exposure, including mixed-breed dogs and cats; groups B and C hold the breeds with more frequent or more expensive claims.

Claim frequency and average cost by breed, coloured by K-means group
Claim frequency and average cost by breed, coloured by K-means group

From k-means to a risk grouping method

Since this engagement, the breed grouping has become a general, tested method for any variable with many values, ordered (age, seniority) or not (breed, product). Four formulas carry it. The risk of a group is a ratio of sums, its claims divided by its exposure or its premium, never an average of individual ratios; with Ni and Ei the claims and the exposure (or premium) of policy i and xi its value:

mg=∑i:xi∈gNi∑i:xi∈gEi(1)

For a given number of classes, the partition minimises the dispersion of risk within the classes, each value weighted by its denominator. For one dimension, total dispersion splits exactly into within and between, so the same partition also pushes the classes as far apart as possible; with several dimensions, the within-class dispersion of each is standardised and they are added with declared weights. With mx the rate of value x, wx its denominator, Wg that of class g and m¯ the overall rate:

∑xwx(mx−m¯)2=∑g∑x∈gwx(mx−mg)2+∑gWg(mg−m¯)2(2)

A breed seen on a few policies is first pulled toward the portfolio mean, as much as its exposure is small (Bühlmann-Straub credibility), so that twelve policies without a claim are not read as a zero risk; EPV is the variance within a breed and VHM the variance between breeds:

m~x=Zxmx+(1−Zx)m¯,Zx=wxwx+EPV/VHM
(3)

The number of classes is never set by hand. The classes are learnt on part of the policies and judged on the others by the reduction of the held-out deviance Dd,val(K) they bring on each dimension, averaged with the declared weights ad; the smallest number within two standard errors of the best is kept, and a single class is a valid answer:

G(K)=∑dadGd(K)∑dad,Gd(K)=Dd,val(1)−Dd,val(K)Dd,val(1)
(4)

The two figures below come out of our tool, with only their labels put into words. The map places each breed by its pure premium and its loss ratio, the size of the point following its exposure; the crosses are the class centres; each ellipse is centred on the rates of its class and drawn from the weighted covariance of its members at two standard deviations, the two-dimensional counterpart of a box plot. Small breeds can sit outside their ellipse: they weigh little, and credibility pulls their risk toward the portfolio mean; it is that credibility-weighted value that sets their class. The second figure shows an ordered variable, age, cut into contiguous classes with their confidence bands, and the exposure underneath. Both run on simulated portfolios, as client data stay with the client. The full derivation is in our article on grouping by risk.

Breeds by pure premium and loss ratio, classes with their ellipses (simulated portfolio)
Breeds by pure premium and loss ratio, classes with their ellipses (simulated portfolio)
Age cut into contiguous classes by risk (simulated portfolio)
Age cut into contiguous classes by risk (simulated portfolio)

What the groups revealed

The grouping was not only cosmetic. Over the period, the portfolio paid 49% of premiums in claims, group A 43% and group B 73%. Group C, nine breeds among them Great Danes, Dobermans, French Bulldogs and Weimaraners, paid out 107% of its premiums: these breeds were priced below their cost, and their pure premium was 2.3 times the portfolio average.

Loss ratio by K-means group
Loss ratio by K-means group

From groups to a tariff

The breed groups entered a frequency (Poisson) × severity (Gamma) GLM alongside age band and policy year, and a Tweedie pure-premium GLM as a cross-check. Pure premium rises steadily with age and policy year: a dog aged eight or more in its fourth year of cover costs about 2.8 times the portfolio average. Across model points the GLM estimate tracks the observed pure premium within its interval, and the two model families agree closely.

Observed pure premium against the GLM estimate, dogs by age and policy year
Observed pure premium against the GLM estimate, dogs by age and policy year

Limits

In this engagement the breed groups came from k-means and were built and assessed on the same period; they should be checked on later underwriting years before a full tariff change. The method described above now chooses the number of classes out of sample and credibility-weights the small breeds. Loss ratios depend on the premiums charged at the time, and the smallest groups carry wide intervals.

Source

The method is described in Raphael Sebbah’s article on Medium, where category labels were replaced for confidentiality.

Raphael has a remarkable ability to distil complex actuarial concepts into understandable and actionable insights.

Uri ShemerActuary

Let’s build better decisions together

Tell us about the decision you need to make.

A few lines are enough: your sector, the data you have and what you want to improve. We reply personally with a first view of the approach.

  • A few lines are enough
  • NDA on request
  • Code and documentation handed over