artlib.optimized.backends.torch._TorchSimpleARTMAP

Classes

_TorchSimpleARTMAP

SimpleARTMAP for Classification.

Functions

_to_device(→ torch.Tensor)

Module Contents

artlib.optimized.backends.torch._TorchSimpleARTMAP._to_device(x: torch.Tensor | numpy.ndarray, device, dtype=torch.float32) torch.Tensor
class artlib.optimized.backends.torch._TorchSimpleARTMAP._TorchSimpleARTMAP(module_a: artlib.common.BaseART.BaseART)

Bases: artlib.supervised.SimpleARTMAP.SimpleARTMAP

SimpleARTMAP for Classification.

This module implements SimpleARTMAP as first published in: [13].

SimpleARTMAP is a special case of ARTMAP specifically for classification. It allows the clustering of data samples while enforcing a many-to-one mapping from sample clusters to labels. It accepts an instantiated BaseART module and dynamically adapts the vigilance function to prevent resonance when the many-to-one mapping is violated. This enables SimpleARTMAP to identify discrete clusters belonging to each category label.

_synchronize_torch_results(labels_a_out: numpy.ndarray, weights_arrays: list[numpy.ndarray], cluster_labels_out: numpy.ndarray, incremental: bool = False)
fit(X: numpy.ndarray, y: numpy.ndarray, max_iter: int = 1, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 1e-10, verbose: bool = False, leave_progress_bar: bool = True)

Fit the model to the data.

Parameters:
  • X (np.ndarray) – Data set A.

  • y (np.ndarray) – Data set B.

  • max_iter (int, default=1) – Number of iterations to fit the model on the same data set.

  • match_tracking (Literal, default="MT+") – Method to reset the match.

  • epsilon (float, default=1e-10) – Small value to adjust the vigilance.

  • verbose (bool, default=False) – non functional. Left for compatibility

  • leave_progress_bar (bool, default=True) – non functional. Left for compatibility

Returns:

self – The fitted model.

Return type:

SimpleARTMAP

partial_fit(X: numpy.ndarray, y: numpy.ndarray, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 1e-10)

Partial fit the model to the data.

Parameters:
  • X (np.ndarray) – Data set A.

  • y (np.ndarray) – Data set B.

  • match_tracking (Literal, default="MT+") – Method to reset the match.

  • epsilon (float, default=1e-10) – Small value to adjust the vigilance.

Returns:

self – The partially fitted model.

Return type:

SimpleARTMAP

predict(X: numpy.ndarray, clip: bool = False) numpy.ndarray

Predict labels for the data.

Parameters:
  • X (np.ndarray) – Data set A.

  • clip (bool) – clip the input values to be between the previously seen data limits

Returns:

B labels for the data.

Return type:

np.ndarray

predict_ab(X: numpy.ndarray, clip: bool = False) Tuple[numpy.ndarray, numpy.ndarray]

Predict labels for the data, both A-side and B-side.

Parameters:
  • X (np.ndarray) – Data set A.

  • clip (bool) – clip the input values to be between the previously seen data limits

Returns:

A labels for the data, B labels for the data.

Return type:

tuple[np.ndarray, np.ndarray]