cleverly.learners.ParametricMechanism#

class cleverly.learners.ParametricMechanism(degree: int = 3, clip: float = 1e-06)[source]#

An unpenalized logistic regression of an indicator on a polynomial in logit q.

The design is one column q, the outcome model’s prediction at one arm. The basis is phi(q) = (1, l, l^2, ..., l^degree) with l = logit(clip(q, clip, 1 - clip)).

Parameters:
degreeint

The polynomial degree in logit q.

clipfloat

The basis clip of q before the logit.

Attributes:
coef_ndarray

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

diagnostics_ParametricFitDiagnostics

The fit’s coefficients, convergence and conditioning.

Methods#

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

d phi / d logit(q), zero on a row where the basis clip binds.

Parameters:
xarray_like

(n,) or (n, 1), the prediction q.

Returns:
ndarray

(n, degree + 1), the derivative of each basis column.

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

The basis phi(q).

Parameters:
xarray_like

(n,) or (n, 1), the prediction q.

Returns:
ndarray

(n, degree + 1), the basis.

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

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.

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

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.

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

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#

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