[PYTHON] Causal reasoning using machine learning (organization of causal reasoning methods)

Causal reasoning using machine learning

Rough understanding and memo of when to use causal reasoning using machine learning methods that have been popular in recent years (memorandum) Basically, a flow chart summary of the current causal reasoning method

Introduction

Causal reasoning is a series of statistical methods aimed at answering the cause for the result. In general, statistical approaches such as regression analysis focus on quantifying how changes in X relate to changes in Y. On the other hand, statistical causal reasoning emphasizes determining whether a change in X causes a change in Y and quantifying this causal relationship. The field of fusion of machine learning and causal reasoning, which has become popular in recent years, is used to estimate causal effects under specific conditions. This time, we have roughly organized the proper use of existing causal reasoning methods and methods using machine learning.

Naturally, we will analyze the data we have after clarifying "what and why do you want to know?" Otherwise, I can't see the tactics to take.

General tactics of causal reasoning

Various policies are taken for causal reasoning. Therefore, various methods can be considered to perform causal inference from the data that one has. First, in order to understand causal reasoning structurally, we divide it into two categories. This time, we will identify whether the data we have is experimental data or observation data, and look at typical approaches for each.

policy

  1. Identification of experimental data or observation data
  2. Causal reasoning with experimental data
  3. Causal reasoning with observed data

Causal reasoning with experimental data

In the case of experimental data, the estimation is clearer and easier to understand than the observed data because the experiment was designed to verify the causal effect. In many cases, the analysis is performed so as to approach the RCT (Randomized Controlled Trial) condition. However, the average causal effect estimation during the designed experiment can be estimated by using the classical statistical causal reasoning method. However, there are times when you want to estimate not only the average causal effect, but also the causal effect under specific circumstances and conditions. Therefore, in recent years, it has been made possible by causal reasoning that interweaves machine learning methods.

The experimental data will be broadly divided into four categories.

--Differences in covariates between intervention and non-intervention --Part of the intervention group is non-intervention --Effects differ for each subgroup within the intervention group --Structural understanding of causality

If the data you have is judged to be experimental data, consider it in order from the top. Then perform the desired analysis.


Differences in covariates between intervention and non-intervention

This is a general causal reasoning. Basically, it is assumed that you want to estimate the causal effect between the intervention group and the non-intervention group. At that time, covariates other than treatment (cause) and response (effect) differ between groups. Then, the correct effect cannot be estimated. Therefore, this covariate is adjusted so that it is as equal as possible between the groups, and then the estimation is performed. The main policies are DID, matching, IPW, etc.

→ DID, matching, IPW etc.


Part of the intervention group is non-intervention

Randomly assigned interventions do not always follow (non-compliance) because of the unbiased estimation of intervention effects in experimental studies. If the allocation of interventions is equal to the intervention actually received, the individual has adhered to the assigned intervention. On the other hand, if they are not equal, it is non-compliance. In other words, under non-compliance conditions, the intervention group will be a mixture of different groups of compliance and non-compliance groups. Therefore, it is necessary to estimate the average causal effect limited to the compliance group (LATE).

→ Instrumental variable (IV)


Different subgroups have different effects within the intervention group

Within the intervention group, each sample has a different covariate. Then, when determining the intervention effect for each specific sample, it is necessary to calculate the intervention effect personalized under specific conditions within the intervention group. Causal reasoning using so-called machine learning.

→ HTE(Heterogeneous Treatment Effects)、Uplift Modeling → GRF (Generalized Random Forest) and ORF (Orthogonal Random Forest) estimate the intervention effect without calculating the propensity score. → Meta-Learner estimates the intervention effect from the estimated value using the propensity score after modeling and estimating the effect for each group.


Structural understanding of causality

When one variable affects another, it may act directly or indirectly through a parameter. At this time, it is important to analyze how direct and indirect the effects affecting the variables are. By understanding not only the relationship between the cause and the effect but also the mechanism that caused the result, it becomes possible to analyze which parameter should be changed to obtain a high effect.

→ Mediation analysis


Causal reasoning with observational data

In the case of observation data, many are observed regularly. At that time, it will be used as time series data. On the other hand, if it is not time series data, variables other than the cause and effect variables will be defined. At this time, sufficient knowledge about a specific situation is required. It is necessary to determine the causal structure based on this.

The observation data is divided into cases as follows.

Heterogeneous Treatment Effects (HTE) Individuals differ not only in their background characteristics, but also in their response to specific treatments, interventions, or stimuli. In particular, therapeutic effects may vary systematically depending on treatment trends (Xie et al., 2012). And in the presence of this heterogeneity of effects, the estimation of the Average Treatment Effect (ATE), a classical causal reasoning approach using the main effects, did not always provide sufficient estimation. Therefore, by considering Heterogeneous Treatment Effects (HTE) as an estimation of intervention effects that take into account the effects at a personal level such as background, it is possible to make an estimation that takes into account each of these effects. At that time, causal reasoning is executed using machine learning.

HTE analysis

There are libraries and packages in R and Python. The typical ones are as follows.

R ・ Grf ・ Uplift ・ Llearner

Python ・ EconML ・ CausalML ・ Pylift

reference

・ A bird's-eye view of the causal reasoning that is attracting attention at the Nobel Prize in Economics https://note.com/tak1/n/nf35b48502339 ・ Using Causal Inference to Improve the Uber User Experience https://eng.uber.com/causal-inference-at-uber/ ・ Summary of research on X-Learner https://dev.classmethod.jp/articles/causal-metalearner-xlearner/ ・ Introduction of EconML package (meta-learners edition) https://usaito.hatenablog.com/entry/2019/04/07/205756 ・ Yu Xie, Jennie E. Brand, and Ben Jann. (2012) Estimating Heterogeneous Treatment Effects with Observational Data. Sociol Methodol 42 (1): 314-347.

Recommended Posts

Causal reasoning using machine learning (organization of causal reasoning methods)
Full disclosure of methods used in machine learning
[Causal search / causal reasoning] Execute causal search (SAM) using deep learning
Try using Jupyter Notebook of Azure Machine Learning
Basics of Machine Learning (Notes)
Importance of machine learning datasets
[Machine learning] Feature selection of categorical variables using chi-square test
Machine learning ③ Summary of decision tree
Application development using Azure Machine Learning
[Python machine learning] Recommendation of using Spyder for beginners (as of August 2020)
Machine learning algorithm (generalization of linear regression)
Stock price forecast using machine learning (scikit-learn)
[Machine learning] LDA topic classification using scikit-learn
[Machine learning] FX prediction using decision trees
2020 Recommended 20 selections of introductory machine learning books
Machine learning algorithm (implementation of multi-class classification)
[Machine learning] Supervised learning using kernel density estimation
Stock price forecast using machine learning (regression)
[Machine learning] List of frequently used packages
Judgment of igneous rock by machine learning ②
[Machine learning] Regression analysis using scikit learn
[Super Introduction] Machine learning using Python-From environment construction to implementation of simple perceptron-
Machine Learning: Image Recognition of MNIST by using PCA and Gaussian Native Bayes
I tried to implement various methods for machine learning (prediction model) using scikit-learn.
A memorandum of method often used in machine learning using scikit-learn (for beginners)
Machine learning memo of a fledgling engineer Part 1
Classification of guitar images by machine learning Part 1
A story about simple machine learning using TensorFlow
Data supply tricks using deques in machine learning
Beginning of machine learning (recommended teaching materials / information)
Machine learning of sports-Analysis of J-League as an example-②
Python & Machine Learning Study Memo ⑤: Classification of irises
Numerai Tournament-Fusion of Traditional Quants and Machine Learning-
Python & Machine Learning Study Memo ②: Introduction of Library
[Machine learning] Supervised learning using kernel density estimation Part 2
Face image dataset sorting using machine learning model (# 3)
List of links that machine learning beginners are learning
[Python3] Let's analyze data using machine learning! (Regression)
About the development contents of machine learning (Example)
Analysis of shared space usage by machine learning
[Translation] scikit-learn 0.18 Tutorial Introduction of machine learning by scikit-learn
Machine learning memo of a fledgling engineer Part 2
Reasonable price estimation of Mercari by machine learning
Classification of guitar images by machine learning Part 2
Get a glimpse of machine learning in Python
Arrangement of self-mentioned things related to machine learning
[Machine learning] Extract similar words mechanically using WordNet
Calculation of support vector machine (SVM) (using cvxopt)
[Memo] Machine learning
Machine learning classification
Machine Learning sample
What I learned about AI / machine learning using Python (1)
Key points of "Machine learning with Azure ML Studio"
[Recommended tagging for machine learning # 2.5] Modification of scraping script
Create machine learning projects at explosive speed using templates
About data preprocessing of systems that use machine learning
Impressions of taking the Udacity Machine Learning Engineer Nano-degree
Installation of TensorFlow, a machine learning library from Google
About testing in the implementation of machine learning models
Predict the gender of Twitter users with machine learning
What I learned about AI / machine learning using Python (3)