Documentation
Classes
CalibratedClassifierCV

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 method implemented when probabilities=True for sklearn.svm estimators.

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.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new CalibratedClassifierCV(opts?: object): CalibratedClassifierCV;

Parameters

NameTypeDescription
opts?object-
opts.base_estimator?anyThis parameter is deprecated. Use estimator instead.
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. Default Value true
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. Default Value 'sigmoid'
opts.n_jobs?numberNumber of jobs to run in parallel. undefined means 1 unless in a joblib.parallel\_backend (opens in a new tab) 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 (opens in a new tab)

Methods

dispose()

Disposes of the underlying Python resources.

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

Signature

dispose(): Promise<void>;

Returns

Promise<void>

Defined in: generated/calibration/CalibratedClassifierCV.ts:137 (opens in a new tab)

fit()

Fit the calibrated model.

Signature

fit(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Training data.
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.y?ArrayLikeTarget values.

Returns

Promise<any>

Defined in: generated/calibration/CalibratedClassifierCV.ts:154 (opens in a new tab)

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Signature

get_metadata_routing(opts: object): Promise<any>;

Parameters

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

Returns

Promise<any>

Defined in: generated/calibration/CalibratedClassifierCV.ts:212 (opens in a new tab)

init()

Initializes the underlying Python resources.

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

Signature

init(py: PythonBridge): Promise<void>;

Parameters

NameType
pyPythonBridge

Returns

Promise<void>

Defined in: generated/calibration/CalibratedClassifierCV.ts:89 (opens in a new tab)

predict()

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.

Signature

predict(opts: object): Promise<ArrayLike>;

Parameters

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

Returns

Promise<ArrayLike>

Defined in: generated/calibration/CalibratedClassifierCV.ts:252 (opens in a new tab)

predict_proba()

Calibrated probabilities of classification.

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

Signature

predict_proba(opts: object): Promise<ArrayLike[]>;

Parameters

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

Returns

Promise<ArrayLike[]>

Defined in: generated/calibration/CalibratedClassifierCV.ts:291 (opens in a new tab)

score()

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.

Signature

score(opts: object): Promise<number>;

Parameters

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

Returns

Promise<number>

Defined in: generated/calibration/CalibratedClassifierCV.ts:331 (opens in a new tab)

set_fit_request()

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:

Signature

set_fit_request(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample\_weight parameter in fit.

Returns

Promise<any>

Defined in: generated/calibration/CalibratedClassifierCV.ts:384 (opens in a new tab)

set_score_request()

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:

Signature

set_score_request(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample\_weight parameter in score.

Returns

Promise<any>

Defined in: generated/calibration/CalibratedClassifierCV.ts:426 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/calibration/CalibratedClassifierCV.ts:27 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/calibration/CalibratedClassifierCV.ts:26 (opens in a new tab)

_py

PythonBridge

Defined in: generated/calibration/CalibratedClassifierCV.ts:25 (opens in a new tab)

id

string

Defined in: generated/calibration/CalibratedClassifierCV.ts:22 (opens in a new tab)

opts

any

Defined in: generated/calibration/CalibratedClassifierCV.ts:23 (opens in a new tab)

Accessors

calibrated_classifiers_

The list of classifier and calibrator pairs.

Signature

calibrated_classifiers_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/calibration/CalibratedClassifierCV.ts:545 (opens in a new tab)

classes_

The class labels.

Signature

classes_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/calibration/CalibratedClassifierCV.ts:464 (opens in a new tab)

feature_names_in_

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

Signature

feature_names_in_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/calibration/CalibratedClassifierCV.ts:518 (opens in a new tab)

n_features_in_

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

Signature

n_features_in_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/calibration/CalibratedClassifierCV.ts:491 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/calibration/CalibratedClassifierCV.ts:76 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/calibration/CalibratedClassifierCV.ts:80 (opens in a new tab)