Calibration methods

class pycalib.models.calibrators.BinningCalibration(n_bins=10, strategy: Literal['uniform', 'quantile', 'kmeans'] = 'uniform', alpha=1.0)

Probability calibration with Binning calibration.

Parameters:
n_bins: integer or list of integers

If integer, the number of bins to create in the score space in order to compute the true fraction of positives during the training. If a list of integers, a BinningCalibration method will be fitted for each number of bins, and the best calibrator evaluated with the validation set will be selected as final calibrator.

strategy: str {‘uniform’, ‘quantile’, ‘kmeans’}

If uniform: for equal width bins If quantile: for equal frequency bins If kmeans: for each bin with same nearest center to a 1D k-means

alpha: float

Laplace smoothing (x + a)/(N + 2a)

References

[1]

Obtaining calibrated probability estimates from decision trees and naive Bayesian classifiers, B. Zadrozny & C. Elkan, ICML 2001

Attributes:
classes_array, shape (n_classes)

The class labels.

calibrated_classifiers_: list (len() equal to cv or 1 if cv == “prefit”)

The list of calibrated classifiers, one for each cross-validation fold, which has been fitted on all but the validation fold and calibrated on the validation fold.

Methods

fit(scores, y[, X_val, y_val])

Score=0 corresponds to y=0, and score=1 to y=1 Parameters ---------- scores : array-like, shape = [n_samples,] Data. y : array-like, shape = [n_samples, ] Labels. Returns ------- self.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

score(X, y[, sample_weight])

Return the coefficient of determination of the prediction.

set_fit_request(*[, X_val, scores, y_val])

Request metadata passed to the fit method.

set_params(**params)

Set the parameters of this estimator.

set_predict_proba_request(*[, scores])

Request metadata passed to the predict_proba method.

set_predict_request(*[, scores])

Request metadata passed to the predict method.

set_score_request(*[, sample_weight])

Request metadata passed to the score method.

predict

predict_proba

fit(scores, y, X_val=None, y_val=None, *args, **kwargs)

Score=0 corresponds to y=0, and score=1 to y=1 Parameters ———- scores : array-like, shape = [n_samples,]

Data.

yarray-like, shape = [n_samples, ]

Labels.

Returns

self

set_fit_request(*, X_val: bool | None | str = '$UNCHANGED$', scores: bool | None | str = '$UNCHANGED$', y_val: bool | None | str = '$UNCHANGED$') BinningCalibration

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see 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.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

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

Metadata routing for X_val parameter in fit.

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

Metadata routing for scores parameter in fit.

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

Metadata routing for y_val parameter in fit.

Returns:
selfobject

The updated object.

set_predict_proba_request(*, scores: bool | None | str = '$UNCHANGED$') BinningCalibration

Request metadata passed to the predict_proba method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see 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.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

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

Metadata routing for scores parameter in predict_proba.

Returns:
selfobject

The updated object.

set_predict_request(*, scores: bool | None | str = '$UNCHANGED$') BinningCalibration

Request metadata passed to the predict method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see 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.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

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

Metadata routing for scores parameter in predict.

Returns:
selfobject

The updated object.

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') BinningCalibration

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score 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 score.

  • 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.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

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

Metadata routing for sample_weight parameter in score.

Returns:
selfobject

The updated object.

class pycalib.models.calibrators.CalibratedModel(base_estimator=None, calibrator=None, fit_estimator=True)

Initialize a Calibrated model (classifier + calibrator)

Parameters:
base_estimatorinstance BaseEstimator

The classifier whose output decision function needs to be calibrated to offer more accurate predict_proba outputs. If cv=prefit, the classifier must have been fit already on data.

calibratorinstance BaseEstimator

The calibrator to use.

Methods

fit(X, y[, X_val, y_val])

Fit the calibrated model

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

predict(X)

Predict the target of new samples.

predict_proba(X)

Posterior probabilities of classification

score(X, y[, sample_weight])

Return the mean accuracy on the given test data and labels.

set_fit_request(*[, X_val, y_val])

Request metadata passed to the fit method.

set_params(**params)

Set the parameters of this estimator.

set_score_request(*[, sample_weight])

Request metadata passed to the score method.

fit(X, y, X_val=None, y_val=None, *args, **kwargs)

Fit the calibrated model

Parameters:
Xarray-like, shape (n_samples, n_features)

Training data.

yarray-like, shape (n_samples, n_classes)

Target values.

Returns:
selfobject

Returns an instance of self.

predict(X)

Predict the target of new samples. Can be different from the prediction of the uncalibrated classifier.

Parameters:
Xarray-like, shape (n_samples, n_features)

The samples.

Returns:
Carray, shape (n_samples,)

The predicted class.

predict_proba(X)

Posterior probabilities of classification

This function returns posterior probabilities of classification according to each class on an array of test vectors X.

Parameters:
Xarray-like, shape (n_samples, n_features)

The samples.

Returns:
Carray, shape (n_samples, n_classes)

The predicted probas. Can be exact zeros.

set_fit_request(*, X_val: bool | None | str = '$UNCHANGED$', y_val: bool | None | str = '$UNCHANGED$') CalibratedModel

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see 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.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

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

Metadata routing for X_val parameter in fit.

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

Metadata routing for y_val parameter in fit.

Returns:
selfobject

The updated object.

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') CalibratedModel

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score 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 score.

  • 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.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

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

Metadata routing for sample_weight parameter in score.

Returns:
selfobject

The updated object.

class pycalib.models.calibrators.IsotonicCalibration

Methods

fit(scores, y, *args, **kwargs)

Score=0 corresponds to y=0, and score=1 to y=1 Parameters ---------- scores : array-like, shape = [n_samples,] Data. y : array-like, shape = [n_samples, ] Labels. Returns ------- self.

fit_transform(X[, y])

Fit to data, then transform it.

get_feature_names_out([input_features])

Get output feature names for transformation.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

predict(scores, *args, **kwargs)

Predict new data by linear interpolation.

score(X, y[, sample_weight])

Return the coefficient of determination of the prediction.

set_fit_request(*[, scores])

Request metadata passed to the fit method.

set_output(*[, transform])

Set output container.

set_params(**params)

Set the parameters of this estimator.

set_predict_proba_request(*[, scores])

Request metadata passed to the predict_proba method.

set_predict_request(*[, scores])

Request metadata passed to the predict method.

set_score_request(*[, sample_weight])

Request metadata passed to the score method.

set_transform_request(*[, T])

Request metadata passed to the transform method.

transform(T)

Transform new data by linear interpolation.

predict_proba

fit(scores, y, *args, **kwargs)

Score=0 corresponds to y=0, and score=1 to y=1 Parameters ———- scores : array-like, shape = [n_samples,]

Data.

yarray-like, shape = [n_samples, ]

Labels.

Returns

self

predict(scores, *args, **kwargs)

Predict new data by linear interpolation.

Parameters:
Tarray-like of shape (n_samples,) or (n_samples, 1)

Data to transform.

Returns:
y_predndarray of shape (n_samples,)

Transformed data.

set_fit_request(*, scores: bool | None | str = '$UNCHANGED$') IsotonicCalibration

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see 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.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

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

Metadata routing for scores parameter in fit.

Returns:
selfobject

The updated object.

set_predict_proba_request(*, scores: bool | None | str = '$UNCHANGED$') IsotonicCalibration

Request metadata passed to the predict_proba method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see 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.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

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

Metadata routing for scores parameter in predict_proba.

Returns:
selfobject

The updated object.

set_predict_request(*, scores: bool | None | str = '$UNCHANGED$') IsotonicCalibration

Request metadata passed to the predict method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see 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.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

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

Metadata routing for scores parameter in predict.

Returns:
selfobject

The updated object.

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') IsotonicCalibration

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score 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 score.

  • 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.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

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

Metadata routing for sample_weight parameter in score.

Returns:
selfobject

The updated object.

set_transform_request(*, T: bool | None | str = '$UNCHANGED$') IsotonicCalibration

Request metadata passed to the transform method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to transform 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 transform.

  • 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.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

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

Metadata routing for T parameter in transform.

Returns:
selfobject

The updated object.

class pycalib.models.calibrators.LogisticCalibration(C=1.0, solver='lbfgs', multi_class='multinomial', log_transform=True)

Probability calibration with Logistic Regression aka Platt’s scaling

Parameters:
C: integer
solver: str ‘lbfgs’
multi_class: str ‘multinomial’
log_transform: boolean True

References

[3]

Probabilistic Outputs for Support Vector Machines and Comparisons to Regularized Likelihood Methods, J. Platt, (1999)

Attributes:
classes_array, shape (n_classes)

The class labels.

calibrated_classifiers_: list (len() equal to cv or 1 if cv == “prefit”)

The list of calibrated classifiers, one for each cross-validation fold, which has been fitted on all but the validation fold and calibrated on the validation fold.

Methods

decision_function(X)

Predict confidence scores for samples.

densify()

Convert coefficient matrix to dense array format.

fit(scores, y[, X_val, y_val])

Fit the model according to the given training data.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

predict(scores, *args, **kwargs)

Predict class labels for samples in X.

predict_log_proba(X)

Predict logarithm of probability estimates.

predict_proba(scores, *args, **kwargs)

Probability estimates.

score(X, y[, sample_weight])

Return the mean accuracy on the given test data and labels.

set_fit_request(*[, X_val, scores, y_val])

Request metadata passed to the fit method.

set_params(**params)

Set the parameters of this estimator.

set_predict_proba_request(*[, scores])

Request metadata passed to the predict_proba method.

set_predict_request(*[, scores])

Request metadata passed to the predict method.

set_score_request(*[, sample_weight])

Request metadata passed to the score method.

sparsify()

Convert coefficient matrix to sparse format.

fit(scores, y, X_val=None, y_val=None, *args, **kwargs)

Fit the model according to the given training data.

Parameters:
X{array-like, sparse matrix} of shape (n_samples, n_features)

Training vector, where n_samples is the number of samples and n_features is the number of features.

yarray-like of shape (n_samples,)

Target vector relative to X.

sample_weightarray-like of shape (n_samples,) default=None

Array of weights that are assigned to individual samples. If not provided, then each sample is given unit weight.

New in version 0.17: sample_weight support to LogisticRegression.

Returns:
self

Fitted estimator.

Notes

The SAGA solver supports both float64 and float32 bit arrays.

predict(scores, *args, **kwargs)

Predict class labels for samples in X.

Parameters:
X{array-like, sparse matrix} of shape (n_samples, n_features)

The data matrix for which we want to get the predictions.

Returns:
y_predndarray of shape (n_samples,)

Vector containing the class labels for each sample.

predict_proba(scores, *args, **kwargs)

Probability estimates.

The returned estimates for all classes are ordered by the label of classes.

For a multi_class problem, if multi_class is set to be “multinomial” the softmax function is used to find the predicted probability of each class. Else use a one-vs-rest approach, i.e calculate the probability of each class assuming it to be positive using the logistic function. and normalize these values across all the classes.

Parameters:
Xarray-like of shape (n_samples, n_features)

Vector to be scored, where n_samples is the number of samples and n_features is the number of features.

Returns:
Tarray-like of shape (n_samples, n_classes)

Returns the probability of the sample for each class in the model, where classes are ordered as they are in self.classes_.

set_fit_request(*, X_val: bool | None | str = '$UNCHANGED$', scores: bool | None | str = '$UNCHANGED$', y_val: bool | None | str = '$UNCHANGED$') LogisticCalibration

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see 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.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

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

Metadata routing for X_val parameter in fit.

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

Metadata routing for scores parameter in fit.

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

Metadata routing for y_val parameter in fit.

Returns:
selfobject

The updated object.

set_predict_proba_request(*, scores: bool | None | str = '$UNCHANGED$') LogisticCalibration

Request metadata passed to the predict_proba method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see 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.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

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

Metadata routing for scores parameter in predict_proba.

Returns:
selfobject

The updated object.

set_predict_request(*, scores: bool | None | str = '$UNCHANGED$') LogisticCalibration

Request metadata passed to the predict method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see 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.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

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

Metadata routing for scores parameter in predict.

Returns:
selfobject

The updated object.

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') LogisticCalibration

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score 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 score.

  • 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.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

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

Metadata routing for sample_weight parameter in score.

Returns:
selfobject

The updated object.

class pycalib.models.calibrators.SigmoidCalibration

Methods

fit(scores, y, *args, **kwargs)

Fit the model using X, y as training data.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

predict(*args, **kwargs)

Predict new data by linear interpolation.

score(X, y[, sample_weight])

Return the coefficient of determination of the prediction.

set_fit_request(*[, scores])

Request metadata passed to the fit method.

set_params(**params)

Set the parameters of this estimator.

set_predict_proba_request(*[, scores])

Request metadata passed to the predict_proba method.

set_predict_request(*[, T])

Request metadata passed to the predict method.

set_score_request(*[, sample_weight])

Request metadata passed to the score method.

predict_proba

fit(scores, y, *args, **kwargs)

Fit the model using X, y as training data.

Parameters:
Xarray-like of shape (n_samples,)

Training data.

yarray-like of shape (n_samples,)

Training target.

sample_weightarray-like of shape (n_samples,), default=None

Sample weights. If None, then samples are equally weighted.

Returns:
selfobject

Returns an instance of self.

predict(*args, **kwargs)

Predict new data by linear interpolation.

Parameters:
Tarray-like of shape (n_samples,)

Data to predict from.

Returns:
T_ndarray of shape (n_samples,)

The predicted data.

set_fit_request(*, scores: bool | None | str = '$UNCHANGED$') SigmoidCalibration

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see 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.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

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

Metadata routing for scores parameter in fit.

Returns:
selfobject

The updated object.

set_predict_proba_request(*, scores: bool | None | str = '$UNCHANGED$') SigmoidCalibration

Request metadata passed to the predict_proba method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see 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.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

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

Metadata routing for scores parameter in predict_proba.

Returns:
selfobject

The updated object.

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') SigmoidCalibration

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score 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 score.

  • 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.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

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

Metadata routing for sample_weight parameter in score.

Returns:
selfobject

The updated object.