Experiments with EconML and Causal Learning: Customer Segmentation
Health economics
Author
Drew Day
Published
January 31, 2025
Introduction
This document will cover practical examples of the use of causal machine learning in the context of business strategy. It draws heavily from and then expands on the “Customer Scenarios” included in the EconML Python package documentation.
Case Study 1: Customer Segmentation
When developing a strategy to
Getting started: Importing and cleaning data
Source Code
#key importsimport numpy as npimport pandas as pdimport matplotlib.pyplot as pltfrom sklearn.preprocessing import PolynomialFeaturesfrom sklearn.ensemble import GradientBoostingRegressorfrom econml.dml import LinearDML, CausalForestDMLfrom econml.cate_interpreter import SingleTreeCateInterpreter, SingleTreePolicyInterpreter#Load datafile_url ="https://msalicedatapublic.z5.web.core.windows.net/datasets/Pricing/pricing_sample.csv"train_data = pd.read_csv(file_url)train_data.head()