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 isphi(q) = (1, l, l^2, ..., l^degree)withl = logit(clip(q, clip, 1 - clip)).- Parameters:
- Attributes:
- coef_
ndarray The fitted coefficients, in the column order of
design_matrix().- diagnostics_
ParametricFitDiagnostics The fit’s coefficients, convergence and conditioning.
- coef_
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 predictionq.
- 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 predictionq.
- 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
fitmethod.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(seesklearn.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 tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.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:
- Returns:
- self
object The updated object.
- self
- ParametricMechanism.set_predict_proba_request(*, x: bool | None | str = '$UNCHANGED$') ParametricMechanism#
Configure whether metadata should be requested to be passed to the
predict_probamethod.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(seesklearn.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 topredict_probaif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict_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.
- ParametricMechanism.set_predict_request(*, x: bool | None | str = '$UNCHANGED$') ParametricMechanism#
Configure whether metadata should be requested to be passed to the
predictmethod.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(seesklearn.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 topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.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.
Attributes#
- ParametricMechanism.diagnostics_: ParametricFitDiagnostics#