DocumentationClassesCalibratedClassifierCV

Class: CalibratedClassifierCV

Probability calibration with isotonic regression or logistic regression.

This class uses cross-validation to both estimate the parameters of a classifier and subsequently calibrate a classifier. With default ensemble=True, for each cv split it fits a copy of the base estimator to the training subset, and calibrates it using the testing subset. For prediction, predicted probabilities are averaged across these individual calibrated classifiers. When ensemble=False, cross-validation is used to obtain unbiased predictions, via cross_val_predict, which are then used for calibration. For prediction, the base estimator, trained using all the data, is used. This is the prediction method implemented when probabilities=True for SVC and NuSVC estimators (see User Guide for details).

Already fitted classifiers can be calibrated via the parameter cv="prefit". In this case, no cross-validation is used and all provided data is used for calibration. The user has to take care manually that data for model fitting and calibration are disjoint.

The calibration is based on the decision_function method of the estimator if it exists, else on predict_proba.

Read more in the User Guide. In order to learn more on the CalibratedClassifierCV class, see the following calibration examples: Probability calibration of classifiers, Probability Calibration curves, and Probability Calibration for 3-class classification.

Python Reference

Constructors

new CalibratedClassifierCV()

new CalibratedClassifierCV(opts?): CalibratedClassifierCV

Parameters

ParameterTypeDescription
opts?object-
opts.cv?number | "prefit"Determines the cross-validation splitting strategy. Possible inputs for cv are:
opts.ensemble?booleanDetermines how the calibrator is fitted when cv is not 'prefit'. Ignored if cv='prefit'. If true, the estimator is fitted using training data, and calibrated using testing data, for each cv fold. The final estimator is an ensemble of n_cv fitted classifier and calibrator pairs, where n_cv is the number of cross-validation folds. The output is the average predicted probabilities of all pairs. If false, cv is used to compute unbiased predictions, via cross_val_predict, which are then used for calibration. At prediction time, the classifier used is the estimator trained on all the data. Note that this method is also internally implemented in sklearn.svm estimators with the probabilities=True parameter.
opts.estimator?anyThe classifier whose output need to be calibrated to provide more accurate predict_proba outputs. The default classifier is a LinearSVC.
opts.method?"sigmoid" | "isotonic"The method to use for calibration. Can be ‘sigmoid’ which corresponds to Platt’s method (i.e. a logistic regression model) or ‘isotonic’ which is a non-parametric approach. It is not advised to use isotonic calibration with too few calibration samples (<<1000) since it tends to overfit.
opts.n_jobs?numberNumber of jobs to run in parallel. undefined means 1 unless in a joblib.parallel_backend context. \-1 means using all processors. Base estimator clones are fitted in parallel across cross-validation iterations. Therefore parallelism happens only when cv != "prefit". See Glossary for more details.

Returns CalibratedClassifierCV

Defined in generated/calibration/CalibratedClassifierCV.ts:29

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/calibration/CalibratedClassifierCV.ts:27
_isInitializedbooleanfalsegenerated/calibration/CalibratedClassifierCV.ts:26
_pyPythonBridgeundefinedgenerated/calibration/CalibratedClassifierCV.ts:25
idstringundefinedgenerated/calibration/CalibratedClassifierCV.ts:22
optsanyundefinedgenerated/calibration/CalibratedClassifierCV.ts:23

Accessors

calibrated_classifiers_

Get Signature

get calibrated_classifiers_(): Promise<number>

The list of classifier and calibrator pairs.

Returns Promise<number>

Defined in generated/calibration/CalibratedClassifierCV.ts:514


classes_

Get Signature

get classes_(): Promise<ArrayLike>

The class labels.

Returns Promise<ArrayLike>

Defined in generated/calibration/CalibratedClassifierCV.ts:433


feature_names_in_

Get Signature

get feature_names_in_(): Promise<ArrayLike>

Names of features seen during fit. Only defined if the underlying estimator exposes such an attribute when fit.

Returns Promise<ArrayLike>

Defined in generated/calibration/CalibratedClassifierCV.ts:487


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit. Only defined if the underlying estimator exposes such an attribute when fit.

Returns Promise<number>

Defined in generated/calibration/CalibratedClassifierCV.ts:460


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/calibration/CalibratedClassifierCV.ts:71

Methods

dispose()

dispose(): Promise<void>

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Returns Promise<void>

Defined in generated/calibration/CalibratedClassifierCV.ts:127


fit()

fit(opts): Promise<any>

Fit the calibrated model.

Parameters

ParameterTypeDescription
optsobject-
opts.fit_params?anyParameters to pass to the fit method of the underlying classifier.
opts.sample_weight?ArrayLikeSample weights. If undefined, then samples are equally weighted.
opts.X?ArrayLike[]Training data.
opts.y?ArrayLikeTarget values.

Returns Promise<any>

Defined in generated/calibration/CalibratedClassifierCV.ts:144


get_metadata_routing()

get_metadata_routing(opts): Promise<any>

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Parameters

ParameterTypeDescription
optsobject-
opts.routing?anyA MetadataRouter encapsulating routing information.

Returns Promise<any>

Defined in generated/calibration/CalibratedClassifierCV.ts:195


init()

init(py): Promise<void>

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/calibration/CalibratedClassifierCV.ts:84


predict()

predict(opts): Promise<ArrayLike>

Predict the target of new samples.

The predicted class is the class that has the highest probability, and can thus be different from the prediction of the uncalibrated classifier.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]The samples, as accepted by estimator.predict.

Returns Promise<ArrayLike>

Defined in generated/calibration/CalibratedClassifierCV.ts:233


predict_proba()

predict_proba(opts): Promise<ArrayLike[]>

Calibrated probabilities of classification.

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

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]The samples, as accepted by estimator.predict_proba.

Returns Promise<ArrayLike[]>

Defined in generated/calibration/CalibratedClassifierCV.ts:271


score()

score(opts): Promise<number>

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

In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?ArrayLikeSample weights.
opts.X?ArrayLike[]Test samples.
opts.y?ArrayLikeTrue labels for X.

Returns Promise<number>

Defined in generated/calibration/CalibratedClassifierCV.ts:309


set_fit_request()

set_fit_request(opts): Promise<any>

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:

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample_weight parameter in fit.

Returns Promise<any>

Defined in generated/calibration/CalibratedClassifierCV.ts:357


set_score_request()

set_score_request(opts): Promise<any>

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:

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample_weight parameter in score.

Returns Promise<any>

Defined in generated/calibration/CalibratedClassifierCV.ts:397