artlib.supervised.ARTMAP ======================== .. py:module:: artlib.supervised.ARTMAP .. autoapi-nested-parse:: ARTMAP :cite:`carpenter1991artmap`. Classes ------- .. autoapisummary:: artlib.supervised.ARTMAP.ARTMAP Module Contents --------------- .. py:class:: ARTMAP(module_a: artlib.common.BaseART.BaseART, module_b: artlib.common.BaseART.BaseART) Bases: :py:obj:`artlib.supervised.SimpleARTMAP.SimpleARTMAP` ARTMAP for Classification and Regression. This module implements ARTMAP as first published in: :cite:`carpenter1991artmap`. .. # Carpenter, G. A., Grossberg, S., & Reynolds, J. H. (1991a). .. # ARTMAP: Supervised real-time learning and classification of nonstationary data .. # by a self-organizing neural network. .. # Neural Networks, 4, 565 – 588. doi:10.1016/0893-6080(91)90012-T. ARTMAP accepts two :class:`~artlib.common.BaseART.BaseART` modules A and B which cluster the dependent channel (samples) and the independent channel (labels) respectively while linking them with a many-to-one mapping. If your labels are integers, use :class:`~artlib.supervised.SimpleARTMAP.SimpleARTMAP` for a faster and more direct implementation. ARTMAP also provides the ability to fit a regression model to data and specific functions have been implemented to allow this. However, :class:`~artlib.fusion.FusionART.FusionART` provides substantially better fit for regression problems which are not monotonic. .. py:attribute:: module_b .. py:method:: get_params(deep: bool = True) -> dict Get the parameters of the ARTMAP model. :param deep: If True, will return the parameters for this class and contained subobjects that are estimators. :type deep: bool, optional :returns: Parameter names mapped to their values. :rtype: dict .. py:property:: labels_a :type: numpy.ndarray Get the labels generated by the A-side ART module. :returns: Labels for the A-side data (independent channel). :rtype: np.ndarray .. py:property:: labels_b :type: numpy.ndarray Get the labels generated by the B-side ART module. :returns: Labels for the B-side data (dependent channel). :rtype: np.ndarray .. py:property:: labels_ab :type: Dict[str, numpy.ndarray] Get the labels generated by both the A-side and B-side ART modules. :returns: Dictionary containing both A-side and B-side labels. :rtype: dict .. py:method:: validate_data(X: numpy.ndarray, y: numpy.ndarray) Validate the input data prior to clustering. :param X: Data set A (independent channel). :type X: np.ndarray :param y: Data set B (dependent channel). :type y: np.ndarray .. py:method:: prepare_data(X: numpy.ndarray, y: Optional[numpy.ndarray] = None) -> Union[numpy.ndarray, Tuple[numpy.ndarray, numpy.ndarray]] Prepare data for clustering by normalizing and transforming. :param X: Data set A (independent channel). :type X: np.ndarray :param y: Data set B (dependent channel). :type y: np.ndarray :returns: Normalized data for both channels. :rtype: tuple of np.ndarray .. py:method:: restore_data(X: numpy.ndarray, y: Optional[numpy.ndarray] = None) -> Union[numpy.ndarray, Tuple[numpy.ndarray, numpy.ndarray]] Restore data to its original state before preparation. :param X: Data set A (independent channel). :type X: np.ndarray :param y: Data set B (dependent channel). :type y: np.ndarray :returns: Restored data for both channels. :rtype: tuple of np.ndarray .. py:method:: fit(X: numpy.ndarray, y: numpy.ndarray, max_iter=1, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 1e-10, verbose: bool = False, leave_progress_bar: bool = True) Fit the ARTMAP model to the data. :param X: Data set A (independent channel). :type X: np.ndarray :param y: Data set B (dependent channel). :type y: np.ndarray :param max_iter: Number of iterations to fit the model on the same data set. :type max_iter: int, optional :param match_tracking: Method for resetting the vigilance parameter when match criterion fails. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, optional :param epsilon: Small increment to modify the vigilance parameter. :type epsilon: float, optional :param verbose: If True, displays a progress bar during training. :type verbose: bool, default=False :param leave_progress_bar: If True, leaves thge progress of the fitting process. Only used when verbose=True :type leave_progress_bar: bool, default=True :returns: **self** -- Fitted ARTMAP model. :rtype: ARTMAP .. py:method:: partial_fit(X: numpy.ndarray, y: numpy.ndarray, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 1e-10) Partially fit the ARTMAP model to the data. :param X: Data set A (independent channel). :type X: np.ndarray :param y: Data set B (dependent channel). :type y: np.ndarray :param match_tracking: Method for resetting the vigilance parameter when match criterion fails. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, optional :param epsilon: Small increment to modify the vigilance parameter. :type epsilon: float, optional :returns: **self** -- Partially fitted ARTMAP model. :rtype: ARTMAP .. py:method:: predict(X: numpy.ndarray, clip: bool = False) -> numpy.ndarray Predict the labels for the given data. :param X: Data set A (independent channel). :type X: np.ndarray :param clip: clip the input values to be between the previously seen data limits :type clip: bool :returns: Predicted labels for data set B (dependent channel). :rtype: np.ndarray .. py:method:: predict_ab(X: numpy.ndarray, clip: bool = False) -> tuple[numpy.ndarray, numpy.ndarray] Predict both A-side and B-side labels for the given data. :param X: Data set A (independent channel). :type X: np.ndarray :param clip: clip the input values to be between the previously seen data limits :type clip: bool :returns: A labels and B labels for the data. :rtype: tuple of np.ndarray .. py:method:: predict_regression(X: numpy.ndarray, clip: bool = False) -> numpy.ndarray Predict values for the given data using cluster centers. Note: ARTMAP is not recommended for regression. Use FusionART for regression tasks. :param X: Data set A (independent channel). :type X: np.ndarray :param clip: clip the input values to be between the previously seen data limits :type clip: bool :returns: Predicted values using cluster centers. :rtype: np.ndarray