nirs4all.core package

Subpackages

Submodules

Module contents

Core functionality for nirs4all.

This module contains fundamental types, metrics, and task detection logic that are used throughout the library.

class nirs4all.core.TaskType(value)[source]

Bases: str, Enum

Enumeration of machine learning task types.

BINARY_CLASSIFICATION = 'binary_classification'
MULTICLASS_CLASSIFICATION = 'multiclass_classification'
REGRESSION = 'regression'
property is_classification: bool

Check if this is a classification task.

property is_regression: bool

Check if this is a regression task.

nirs4all.core.detect_task_type(y: ndarray, threshold: float = 0.05) TaskType[source]

Detect task type based on target values.

Parameters:
  • y – Target values array

  • threshold – Threshold for determining if values are continuous (regression) vs discrete (classification). For integer values, if n_unique <= max_classes or n_unique <= len(y) * threshold, it’s considered classification.

Returns:

Detected task type

Return type:

TaskType