ergodicDocs
Products: switch from ergodic to another product
Get started

ReferenceRanked decisions

Ranked decisions

Rank explicit single-variable actions using graph-identified causal contrasts. Import from ergodic.decision.

PROTOCOL#

python
PROTOCOL: str = 'decision-contrasts_v1'

Version of intervention defaults, class semantics and ranking policy.

PROTOCOLS#

python
PROTOCOLS: tuple = ('decision-contrasts_v1', 'decision-contrasts_v2')

Protocols decide accepts; the first, PROTOCOL, is the default.

RANKING_METHODS#

python
RANKING_METHODS: tuple = ('plugin', 's', 'dr')

Query-row ranking methods for discrete treatments under decision-contrasts_v2.

ArmDR#

python
class ArmDR(
    *,
    outcome: Any = None,
    propensity: Any = None,
    final: Any = None,
    n_folds: int = 5,
    seed: int = 0,
    min_propensity: float = 0.01,
    keep_outcome_models: bool = True,
) -> None

Cross-fitted categorical-treatment DR with pluggable regression/propensity learners.

Arm labels passed to fit are contiguous integer codes. The caller owns graph identification and label encoding. No arm or outcome is silently dropped. Positivity failures raise instead of clipping weights. Population intervals are asymptotic and do not include graph selection or multiple-comparison error. Query predictions are conditional expectations with no individual intervals. With keep_outcome_models (the default) every fold's arm outcome models are kept after fit for method="plugin" (n_folds x arms models), so memory grows with heavy learners; decide keeps them only when plugin ranking can be used.

ArmDR.fit#

python
def ArmDR.fit(x: FloatArray, a: FloatArray, y: FloatArray) -> ArmDR

Fit fresh fold-specific nuisances; retain scores over every context row.

ArmDR.contrast#

python
def ArmDR.contrast(
    baseline: int,
    value: int,
    query: FloatArray | None = None,
    *,
    method: str = 'dr',
) -> tuple[float, float, FloatArray | None]

Return population mean, paired-score standard error and optional query effects.

The population mean and standard error always come from the paired DR scores; method (plugin, s or dr) only selects how query effects are predicted.

Intervention#

python
class Intervention(
    method: str | None = None,
    baseline: Any = None,
    values: tuple[Any, ...] | None = None,
    kind: str | None = None,
    bandwidth: float | None = None,
    validation_probability: float | None = None,
) -> None

One actionable variable's method and optional explicit dose contrast.

Omitted levels use context mode for discrete variables and median for numeric variables, against other labels or the 25th/75th percentiles respectively. Declare kind='categorical' for integer-coded categories with >2 labels.

Field Type Default
method str | None None
baseline Any None
values tuple[Any, ...] | None None
kind str | None None
bandwidth float | None None
validation_probability float | None None

decide#

python
def decide(
    graph: MixedGraph,
    context: pd.DataFrame,
    *,
    target: str,
    interventions: Mapping[str, Intervention | Mapping[str, Any]],
    rows: pd.DataFrame | None = None,
    objective: str = 'maximize',
    target_kind: str | None = None,
    target_class: Any = None,
    types: Mapping[str, str] | None = None,
    learners: Mapping[str, Any] | None = None,
    n_folds: int = 5,
    seed: int = 0,
    min_propensity: float = 0.01,
    checkpoint: Callable[[], None] | None = None,
    protocol: str = 'decision-contrasts_v1',
    learners_by_variable: Mapping[str, Mapping[str, Any]] | None = None,
    validation: pd.DataFrame | None = None,
    validation_design: str | None = None,
    unit_id: str | None = None,
) -> dict[str, Any]

Identify, estimate and rank single-variable contrasts in one target's units.

context alone determines fits and defaults. rows only supplies query adjustment values. Population effects refer to context; query effects are conditional expectations, not structural individual potential outcomes. Discrete targets report class-probability differences and require a ranking event (defaults to True/1 only for boolean or 0/1 targets). Unidentifiable or unsupported candidates are returned in skipped with explicit reasons. Graph discovery/selection uncertainty is not included in intervals.

Suggest an edit
Documentation

Search ergodic 0.4.0

Search ergodic by task, function or error.