metacausal.adapters.GenericATEAdapter

class metacausal.adapters.GenericATEAdapter(fn, name='custom', supported_outcome_types=('continuous',))[source]

Bases: object

Wrap a callable fn(X, T, Y) -> float as an ATE-only causal estimator.

Parameters:
  • fn (Callable) – A function that takes (X, T, Y) and returns a scalar ATE or a ComponentAteEstimate.

  • name (str) – Display name for this estimator. Default "custom".

  • supported_outcome_types (tuple[str, ...])

Examples

>>> from metacausal.adapters import GenericATEAdapter
>>> from metacausal.datasets import load_lalonde
>>> X, T, Y = load_lalonde()
>>> def naive_diff(X, T, Y):
...     return float(Y[T == 1].mean() - Y[T == 0].mean())
>>> adapter = GenericATEAdapter(naive_diff, name="naive_diff")
>>> adapter.fit(X, T, Y)
>>> adapter.ate()
ComponentAteEstimate(ate=...)

Methods

__init__

ate

cate

fit

validate_outcome_type

No-op: the wrapped callable is opaque, so the user's supported_outcome_types declaration is the contract.

Attributes

Details

ate(X=None)[source]
Parameters:

X (ndarray | None)

Return type:

ComponentAteEstimate

cate(X)[source]
Parameters:

X (ndarray)

Return type:

ComponentCateEstimate

fit(X, T, Y, **kwargs)[source]
Parameters:
Return type:

None

validate_outcome_type(detected)[source]

No-op: the wrapped callable is opaque, so the user’s supported_outcome_types declaration is the contract.

Parameters:

detected (str)

Return type:

None

property name: str
property supports_cate: bool