DocumentationClassesTunedThresholdClassifierCV

Class: TunedThresholdClassifierCV

Classifier that post-tunes the decision threshold using cross-validation.

This estimator post-tunes the decision threshold (cut-off point) that is used for converting posterior probability estimates (i.e. output of predict_proba) or decision scores (i.e. output of decision_function) into a class label. The tuning is done by optimizing a binary metric, potentially constrained by a another metric.

Read more in the User Guide.

Python Reference

Constructors

new TunedThresholdClassifierCV()

new TunedThresholdClassifierCV(opts?): TunedThresholdClassifierCV

Parameters

ParameterTypeDescription
opts?object-
opts.cv?number | "prefit"Determines the cross-validation splitting strategy to train classifier. Possible inputs for cv are:
opts.estimator?anyThe classifier, fitted or not, for which we want to optimize the decision threshold used during predict.
opts.n_jobs?numberThe number of jobs to run in parallel. When cv represents a cross-validation strategy, the fitting and scoring on each data split is done in parallel. undefined means 1 unless in a joblib.parallel_backend context. \-1 means using all processors. See Glossary for more details.
opts.random_state?numberControls the randomness of cross-validation when cv is a float. See Glossary.
opts.refit?booleanWhether or not to refit the classifier on the entire training set once the decision threshold has been found. Note that forcing refit=False on cross-validation having more than a single split will raise an error. Similarly, refit=True in conjunction with cv="prefit" will raise an error.
opts.response_method?"auto" | "predict_proba" | "decision_function"Methods by the classifier estimator corresponding to the decision function for which we want to find a threshold. It can be:
opts.scoring?stringThe objective metric to be optimized. Can be one of:
opts.store_cv_results?booleanWhether to store all scores and thresholds computed during the cross-validation process.
opts.thresholds?number | ArrayLikeThe number of decision threshold to use when discretizing the output of the classifier method. Pass an array-like to manually specify the thresholds to use.

Returns TunedThresholdClassifierCV

Defined in generated/model_selection/TunedThresholdClassifierCV.ts:25

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/model_selection/TunedThresholdClassifierCV.ts:23
_isInitializedbooleanfalsegenerated/model_selection/TunedThresholdClassifierCV.ts:22
_pyPythonBridgeundefinedgenerated/model_selection/TunedThresholdClassifierCV.ts:21
idstringundefinedgenerated/model_selection/TunedThresholdClassifierCV.ts:18
optsanyundefinedgenerated/model_selection/TunedThresholdClassifierCV.ts:19

Accessors

best_score_

Get Signature

get best_score_(): Promise<number>

The optimal score of the objective metric, evaluated at best_threshold_.

Returns Promise<number>

Defined in generated/model_selection/TunedThresholdClassifierCV.ts:528


best_threshold_

Get Signature

get best_threshold_(): Promise<number>

The new decision threshold.

Returns Promise<number>

Defined in generated/model_selection/TunedThresholdClassifierCV.ts:501


cv_results_

Get Signature

get cv_results_(): Promise<any>

A dictionary containing the scores and thresholds computed during the cross-validation process. Only exist if store_cv_results=True. The keys are "thresholds" and "scores".

Returns Promise<any>

Defined in generated/model_selection/TunedThresholdClassifierCV.ts:555


estimator_

Get Signature

get estimator_(): Promise<any>

The fitted classifier used when predicting.

Returns Promise<any>

Defined in generated/model_selection/TunedThresholdClassifierCV.ts:474


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/model_selection/TunedThresholdClassifierCV.ts:609


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/model_selection/TunedThresholdClassifierCV.ts:582


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/model_selection/TunedThresholdClassifierCV.ts:85

Methods

decision_function()

decision_function(opts): Promise<ArrayLike>

Decision function for samples in X using the fitted estimator.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeTraining vectors, where n_samples is the number of samples and n_features is the number of features.

Returns Promise<ArrayLike>

Defined in generated/model_selection/TunedThresholdClassifierCV.ts:158


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/model_selection/TunedThresholdClassifierCV.ts:141


fit()

fit(opts): Promise<any>

Fit the classifier.

Parameters

ParameterTypeDescription
optsobject-
opts.params?anyParameters to pass to the fit method of the underlying classifier.
opts.X?ArrayLikeTraining data.
opts.y?ArrayLikeTarget values.

Returns Promise<any>

Defined in generated/model_selection/TunedThresholdClassifierCV.ts:194


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/model_selection/TunedThresholdClassifierCV.ts:242


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/model_selection/TunedThresholdClassifierCV.ts:98


predict()

predict(opts): Promise<ArrayLike>

Predict the target of new samples.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeThe samples, as accepted by estimator.predict.

Returns Promise<ArrayLike>

Defined in generated/model_selection/TunedThresholdClassifierCV.ts:278


predict_log_proba()

predict_log_proba(opts): Promise<ArrayLike[]>

Predict logarithm class probabilities for X using the fitted estimator.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeTraining vectors, where n_samples is the number of samples and n_features is the number of features.

Returns Promise<ArrayLike[]>

Defined in generated/model_selection/TunedThresholdClassifierCV.ts:314


predict_proba()

predict_proba(opts): Promise<ArrayLike[]>

Predict class probabilities for X using the fitted estimator.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeTraining vectors, where n_samples is the number of samples and n_features is the number of features.

Returns Promise<ArrayLike[]>

Defined in generated/model_selection/TunedThresholdClassifierCV.ts:350


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/model_selection/TunedThresholdClassifierCV.ts:388


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/model_selection/TunedThresholdClassifierCV.ts:438