metacausal.infer_outcome_type

metacausal.infer_outcome_type(Y)[source]

Detect the outcome type from the values of Y.

Detection is on the value set, not cardinality: continuous Y with only two distinct values is correctly classified as continuous unless those values are exactly {0, 1}. Boolean Y is silently treated as binary. A single-valued Y (only one distinct value) is rejected, since treatment-effect estimation needs at least two levels.

Parameters:

Y (array-like) – Outcome vector. NumPy array, list, pandas Series, etc.

Returns:

“binary” or “continuous”

Raises:

ValueError – If Y has non-numeric dtype, contains NaN, is empty, has only one distinct value, or otherwise cannot be unambiguously classified.

Return type:

Literal[‘continuous’, ‘binary’]