How to create an insurance premium pricing model using Linear Regression, Python and Jupyter


Hello readers!

This article is about computation of cattle insurance premium for financial losses of farmers due to Tiger attacks in the Corbett Reserve National Park. These types of calculations are basic for an insurance company to price the products optimally.

This article is based on one of the CAST (Certificate in Actuarial Software Techniques) project. The project can be viewed from the link below:

As per the given business problem, there are various villages where farmers are suffering from livestock/cattle losses due to tiger attacks. Therefore, they plan to insure themselves through an insurance for their cattle in order to minimize the financial loss.  Being an actuarial aspirant and data science lover, I have tried to calculate the amount which is required to purchase the insurance. I have used Python and Jupyter for this project.

The data can be dowloaded from Data File, Model and Sights.

In this Article, we learn to calculate premium for the financial losses of Farmers due to tiger attacks using Python language. It includes several steps of coding.

  1. Import Libraries
  2. Import Datasets
    1. Data
    2. Model (probability of killing)
    3. Sights
  3. Build Regression Model (Intercept and Coefficient)
  4. Predict the Probabilities
  5. Calculate the Expected Loss
  6. Graph of Expected Loss
  7. Calculation of Premium

Import Libraries

  • Open Jupiter notebook in Anaconda Navigator
  • Import libraries

Import Datasets

  • Data
  • Model
  • Sights

Build Regression Model

Now, we build the regression model.
Where “a” represent the intercept and “b” denotes the coefficient.

Predict the Probabilities

After computing the linear regression model we use these values to predict the probabilities in dataset SIGHTS, where we define our own function to predict the Probability.

Calculate the Expected Loss

Using probabilities and data we compute the figure of expected loss

Graph of Expected Loss

Calculation of Premium

Finally, we compute the premium, it involves two calculations:

  • Consolidated Expected Present Value
  • Premium

Where B is the consolidated EPV of losses and P is the premium.

Consolidated Expected Present Value

Premium Calculation


In this article, we have covered the process of pricing an insurance product for farmers. In the same way, we can compute the premium for other insurance products. Also, using the annuity functions, we can calculate annuity contracts as well. Thanks!

Follow Abhi Saxena:
I am Abhi Saxena and belongs to Kota, Rajasthan. An actuarial science aspirant currently pursuing MSC actuarial Science from AMITY University, also cleared 2 actuarial exams and recently got campus placement in Deloitte. In Nov 2020, IFOA featured me as an ACTUARY OF THE FUTURE in their magazine i.e. "THE ACTUARY".