cleverly.learners.ParametricOutcome#

class cleverly.learners.ParametricOutcome(features: Literal['main_terms', 'arm_interactions', 'arm_interactions_no_intercept'] = 'arm_interactions', arm_columns: int = 1)[source]#

An unpenalized logistic GLM of the outcome on a declared feature map.

The target is binary, or an outcome already scaled to [0, 1] (a quasi-binomial fit). predict returns the fitted mean, and predict_proba returns it as the class 1 column.

Parameters:
features{“main_terms”, “arm_interactions”, “arm_interactions_no_intercept”}

The feature map of OutcomeFeatures.

arm_columnsint

The number of treatment columns that lead the outcome design: 1 for a binary treatment, K - 1 for K arms. A fit refuses a value that differs from the width of the treatment block of its data, with MethodConfigurationError, wherever the learner sits: bare, in a library, or inside a wrapper.

Attributes:
coef_ndarray

The fitted coefficients, in the column order of design_matrix().

diagnostics_ParametricFitDiagnostics

The fit’s coefficients, convergence and conditioning.

Methods#

ParametricOutcome.design_matrix(x: Any) → ndarray[tuple[Any, ...], dtype[float64]][source]#

The outcome feature matrix of the design x, intercept first.

Parameters:
xarray_like

(n, d), the outcome design [I, W] with arm_columns leading treatment columns.

Returns:
ndarray

The feature matrix of OutcomeFeatures.

Raises:
ValueError

If the feature map is not in the vocabulary, or the design has no covariate column.

ParametricOutcome.set_fit_request(*, sample_weight: bool | None | str = '$UNCHANGED$', x: bool | None | str = '$UNCHANGED$') → ParametricOutcome#

Configure whether metadata should be requested to be passed to the fit method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:
sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in fit.

xstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for x parameter in fit.

Returns:
selfobject

The updated object.

ParametricOutcome.set_predict_proba_request(*, x: bool | None | str = '$UNCHANGED$') → ParametricOutcome#

Configure whether metadata should be requested to be passed to the predict_proba method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to predict_proba if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to predict_proba.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:
xstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for x parameter in predict_proba.

Returns:
selfobject

The updated object.

ParametricOutcome.set_predict_request(*, x: bool | None | str = '$UNCHANGED$') → ParametricOutcome#

Configure whether metadata should be requested to be passed to the predict method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to predict.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:
xstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for x parameter in predict.

Returns:
selfobject

The updated object.

Attributes#

ParametricOutcome.coef_: ndarray[tuple[Any, ...], dtype[float64]]#
ParametricOutcome.classes_: ndarray[tuple[Any, ...], dtype[float64]]#
ParametricOutcome.diagnostics_: ParametricFitDiagnostics#