artlib.optimized.backends.torch._TorchSimpleARTMAP ================================================== .. py:module:: artlib.optimized.backends.torch._TorchSimpleARTMAP Classes ------- .. autoapisummary:: artlib.optimized.backends.torch._TorchSimpleARTMAP._TorchSimpleARTMAP Functions --------- .. autoapisummary:: artlib.optimized.backends.torch._TorchSimpleARTMAP._to_device Module Contents --------------- .. py:function:: _to_device(x: Union[torch.Tensor, numpy.ndarray], device, dtype=torch.float32) -> torch.Tensor .. py:class:: _TorchSimpleARTMAP(module_a: artlib.common.BaseART.BaseART) Bases: :py:obj:`artlib.supervised.SimpleARTMAP.SimpleARTMAP` SimpleARTMAP for Classification. This module implements SimpleARTMAP as first published in: :cite:`gotarredona1998adaptive`. .. # Serrano-Gotarredona, T., Linares-Barranco, B., & Andreou, A. G. (1998). .. # Adaptive Resonance Theory Microchips: Circuit Design Techniques. .. # Norwell, MA, USA: Kluwer Academic Publishers. SimpleARTMAP is a special case of :class:`~artlib.supervised.ARTMAP.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 :class:`~artlib.common.BaseART.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. .. py:method:: _synchronize_torch_results(labels_a_out: numpy.ndarray, weights_arrays: list[numpy.ndarray], cluster_labels_out: numpy.ndarray, incremental: bool = False) .. py:method:: 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. :param X: Data set A. :type X: np.ndarray :param y: Data set B. :type y: np.ndarray :param max_iter: Number of iterations to fit the model on the same data set. :type max_iter: int, default=1 :param match_tracking: Method to reset the match. :type match_tracking: Literal, default="MT+" :param epsilon: Small value to adjust the vigilance. :type epsilon: float, default=1e-10 :param verbose: non functional. Left for compatibility :type verbose: bool, default=False :param leave_progress_bar: non functional. Left for compatibility :type leave_progress_bar: bool, default=True :returns: **self** -- The fitted model. :rtype: SimpleARTMAP .. py:method:: 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. :param X: Data set A. :type X: np.ndarray :param y: Data set B. :type y: np.ndarray :param match_tracking: Method to reset the match. :type match_tracking: Literal, default="MT+" :param epsilon: Small value to adjust the vigilance. :type epsilon: float, default=1e-10 :returns: **self** -- The partially fitted model. :rtype: SimpleARTMAP .. py:method:: predict(X: numpy.ndarray, clip: bool = False) -> numpy.ndarray Predict labels for the data. :param X: Data set A. :type X: np.ndarray :param clip: clip the input values to be between the previously seen data limits :type clip: bool :returns: B labels for the data. :rtype: np.ndarray .. py:method:: predict_ab(X: numpy.ndarray, clip: bool = False) -> Tuple[numpy.ndarray, numpy.ndarray] Predict labels for the data, both A-side and B-side. :param X: Data set A. :type X: np.ndarray :param clip: clip the input values to be between the previously seen data limits :type clip: bool :returns: A labels for the data, B labels for the data. :rtype: tuple[np.ndarray, np.ndarray]