Skip to content

1.3. Modularity

Modularity is building analysis, code, systems as a series of building blocks rather than one singular piece.

Rather than having long scripts, these can be broken down into smaller functions, each that do a specific task, which can then be tested and reused across other processes.

Helper Functions

Say we want to query a SQL database, there's a series of steps to get credentials, authorise and connect.

Rather than repeating these each time data is read, this logic could be put into a function, with a parameter for whether it's the test, dev or production database.

This can then be tested and used across multiple processes, and as a bonus some logic to detect the environment automatically so the code connects to the right database depending on where it's being run.

Data Transformations

Very rarely does the raw data get used directly in rating logic or models directly, it will usually undergo cleaning, grouping, and creating new factors.

Ie in Motor, you may have dates of birth for all driver's on a quote, and to calculate the age of youngest driver, you'd take the age of each driver, and then takes the lowest of these.

Rather than repeat this calculation for each process,

Modelling

A lot of the steps when building models can be wrapped up into modules.

Preprocessing, training, validation, deployment, monitoring

Configuration files for each type of model.

Not only can the components be modular, the model itself can be a modular system.

Ie, the competitor model may continually retrain, producing validation packs which are sent out, and automatically pushed to production if certain tests are passed.

Any process that require scores from the model just need to interact with the end points.

Impact Analysis

Building out a the perfect update to your pricing strategy.

A flat elasticity assumption, or maybe one that.

Building a module for properly estimatating impacts, with calls to conversion and renewal models.

Not only does this improve impact analysis, but allows for consistent results across analyitcal pieces.