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)

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:421 (opens in a new tab)

classes_

The class labels.

Signature

classes_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/calibration/CalibratedClassifierCV.ts:340 (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:394 (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:367 (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)

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)

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:212 (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:251 (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:291 (opens in a new tab)