cleverly.TMLEMethod#

class cleverly.TMLEMethod(models: ModelSpec = ModelSpec(outcome_learner=None, treatment_learner=None, missingness_learner=None, intermediate_learner=None, pseudo_learner=None, censoring_learner=None, density_bins=None, ratio='density', screen_treatment=False, screen_threshold=0.1, min_retain=None, outcome_by_arm=False, survival_model='iterated_mean'), cross_fitting: CrossFitting = CrossFitting(enabled=True, n_folds=10, learner_folds=5, repeats=1, stratify_by='none', targeting_scheme='pooled', fold_evaluation=False, split_plan=None), targeting: Targeting = Targeting(fluctuation='logistic', algorithm='iterative', g_bounds='auto', q_bounds=None, nuisance_bound=0.01, submodel_alpha=0.9995, target_weights=False, step_size=0.001, max_iter=20, tol=1e-10, stopping='relative', step_bound=None, step_search=True, iterate='last', isotonic=False), inference: Inference = Inference(alpha=0.05, n_bootstrap=0, bootstrap_resampling='auto', simultaneous=True, n_multiplier='auto', multiplier_kind='rademacher'), runtime: Runtime = Runtime(random_state=None, run_id=None, n_jobs=1), name: str = 'tmle')[source]#

Normalized configuration for the built-in analytic TMLE method.

IdentifiedEffect.estimate(method="tmle", ...) normalizes keyword shortcuts into this object before fitting. Passing one directly gives the same computational path.

Parameters:
modelsModelSpec

Nuisance learners and related model settings.

cross_fittingCrossFitting

Sample-splitting settings.

targetingTargeting

Fluctuation and solver settings.

inferenceInference

Interval and resampling settings.

runtimeRuntime

Seed, run identifier, and parallelism.

namestr

Stable method name.

See also

CollaborativeTMLEMethod

Selects the treatment mechanism against the targeted loss.

DRTMLEMethod

Corrects both nuisances with reduced-dimension regressions.

ModelSpec

The learners this configuration fits with.

cleverly.IdentifiedEffect

What this configuration is passed to.

Examples

>>> from cleverly import CrossFitting, TMLEMethod
>>> method = TMLEMethod(cross_fitting=CrossFitting(n_folds=5), name="tmle")
>>> method.cross_fitting.n_folds
5

The flat shortcuts route to the same fields, so the two spellings agree:

>>> TMLEMethod().with_overrides(n_folds=5) == method
True

Methods#

TMLEMethod.estimator_kwargs(*, longitudinal: bool = False) → dict[str, Any][source]#

Translate normalized groups into the selected engine API.

Parameters:
longitudinalbool

Whether to target the longitudinal engine.

Returns:
dict of str to Any

Engine keyword arguments.

TMLEMethod.with_overrides(**overrides: Any) → TMLEMethod[source]#

Return a copy with flat shortcuts normalized by concern.

Parameters:
**overridesAny

Fields listed in the public shortcut table, such as n_folds or alpha.

Returns:
TMLEMethod

New immutable configuration.

Raises:
MethodConfigurationError

If an option is not supported by the method.

Notes

alpha= sets Inference.alpha, the reported interval’s significance level. Use submodel_alpha= for Targeting.submodel_alpha, the separate logistic-submodel bound.

Attributes#

TMLEMethod.cross_fitting: CrossFitting = CrossFitting(enabled=True, n_folds=10, learner_folds=5, repeats=1, stratify_by='none', targeting_scheme='pooled', fold_evaluation=False, split_plan=None)#
TMLEMethod.inference: Inference = Inference(alpha=0.05, n_bootstrap=0, bootstrap_resampling='auto', simultaneous=True, n_multiplier='auto', multiplier_kind='rademacher')#
TMLEMethod.models: ModelSpec = ModelSpec(outcome_learner=None, treatment_learner=None, missingness_learner=None, intermediate_learner=None, pseudo_learner=None, censoring_learner=None, density_bins=None, ratio='density', screen_treatment=False, screen_threshold=0.1, min_retain=None, outcome_by_arm=False, survival_model='iterated_mean')#
TMLEMethod.name: str = 'tmle'#
TMLEMethod.runtime: Runtime = Runtime(random_state=None, run_id=None, n_jobs=1)#
TMLEMethod.targeting: Targeting = Targeting(fluctuation='logistic', algorithm='iterative', g_bounds='auto', q_bounds=None, nuisance_bound=0.01, submodel_alpha=0.9995, target_weights=False, step_size=0.001, max_iter=20, tol=1e-10, stopping='relative', step_bound=None, step_search=True, iterate='last', isotonic=False)#