autointent.modules.decision.AdaptiveDecision#

class autointent.modules.decision.AdaptiveDecision(search_space=None)#

Bases: autointent.modules.base.BaseDecision

Decision for multi-label classification using adaptive thresholds.

The AdaptiveDecision calculates optimal thresholds based on the given scores and labels, ensuring the best performance on multi-label data.

Parameters:

search_space (list[autointent.custom_types.FloatFromZeroToOne] | None) – List of threshold scaling factors to search for optimal performance. Defaults to a range between 0 and 1

Examples:#

from autointent.modules.decision import AdaptiveDecision
import numpy as np
scores = np.array([[0.8, 0.1, 0.4], [0.2, 0.9, 0.5]])
labels = [[1, 0, 0], [0, 1, 0]]
predictor = AdaptiveDecision()
predictor.fit(scores, labels)
decisions = predictor.predict(scores)
print(decisions)
[[1, 0, 1], [0, 1, 1]]
tags: list[autointent.schemas.Tag] | None#
supports_multilabel = True#

Whether the module supports multilabel classification

supports_multiclass = False#

Whether the module supports multiclass classification

supports_oos = False#

Whether the module supports oos data

name = 'adaptive'#

Name of the module.

search_space = None#
classmethod from_context(context, search_space=None)#

Create an AdaptiveDecision instance using a Context object.

Parameters:
  • context (autointent.Context) – Context containing configurations and utilities

  • search_space (list[autointent.custom_types.FloatFromZeroToOne] | None) – List of threshold scaling factors, or None for default

Return type:

AdaptiveDecision

fit(scores, labels, tags=None)#

Fit the predictor by optimizing the threshold scaling factor.

Parameters:
  • scores (numpy.typing.NDArray[Any]) – Array of shape (n_samples, n_classes) with predicted scores

  • labels (autointent.custom_types.ListOfGenericLabels) – List of true multi-label targets

  • tags (list[autointent.schemas.Tag] | None) – List of Tag objects for mutually exclusive classes, or None

Raises:

WrongClassificationError – If used on non-multi-label data

Return type:

None

predict(scores)#

Predict labels for the given scores.

Parameters:

scores (numpy.typing.NDArray[Any]) – Array of shape (n_samples, n_classes) with predicted scores

Returns:

Array of shape (n_samples, n_classes) with predicted binary labels

Raises:

MismatchNumClassesError – If the number of classes does not match the trained predictor

Return type:

autointent.custom_types.ListOfLabelsWithOOS