CausalEffectEstimation.fitTLearner

CausalEffectEstimation.fitTLearner(**estimator_params)

Fit the T-Learner Estimator.

A basic implementation of the T-learner based on Künzel et al.[1].

Parameters:
  • learner (str or Any, optional) – Base estimator for all learners. If not provided, defaults to LinearRegression.

  • control_learner (str or Any, optional) – Estimator for control group outcome. Overrides learner if specified.

  • treatment_learner (str or Any, optional) – Estimator for treatment group outcome. Overrides learner if specified.

Raises:
Return type:

Any

Example

import numpy as np
import pandas as pd

import pyagrum as gum
import pyagrum.causalEffectEstimation as pycee

rng = np.random.default_rng(42)
X = rng.normal(size=500)
T = (rng.random(500) < 1 / (1 + np.exp(-X))).astype(int)
Y = 2 * T + X + rng.normal(size=500)  # the causal effect of T on Y is 2
df = pd.DataFrame({"X": X, "T": T, "Y": Y})
cee = pycee.CausalEffectEstimation(df, gum.CausalModel(gum.fastBN("X->T->Y;X->Y")))
cee.identifyAdjustmentSet("T", "Y", verbose=False)
# 'Backdoor'
cee.fitTLearner()
round(float(cee.estimateCausalEffect()), 1)
# 2.1

Class

CausalEffectEstimation