artlib.hierarchical.DeepARTMAP ============================== .. py:module:: artlib.hierarchical.DeepARTMAP .. autoapi-nested-parse:: Deep ARTMAP :cite:`carpenter1991artmap`. Classes ------- .. autoapisummary:: artlib.hierarchical.DeepARTMAP.DeepARTMAP Module Contents --------------- .. py:class:: DeepARTMAP(modules: list[artlib.common.BaseART.BaseART]) Bases: :py:obj:`sklearn.base.BaseEstimator`, :py:obj:`sklearn.base.ClassifierMixin`, :py:obj:`sklearn.base.ClusterMixin` DeepARTMAP for Hierachical Supervised and Unsupervised Learning. This module implements DeepARTMAP, a generalization of the :class:`~artlib.supervised.ARTMAP.ARTMAP` class :cite:`carpenter1991artmap` that allows an arbitrary number of data channels to be divisively clustered. DeepARTMAP support both supervised and unsupervised modes. If only two ART modules are provided, DeepARTMAP reverts to standard :class:`~artlib.supervised.ARTMAP.ARTMAP` where the first module is the A-module and the second module is the B-module. DeepARTMAP does not currently have a direct citation and is an original creation of this library. .. # 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. .. py:attribute:: modules .. py:attribute:: layers :type: list[artlib.common.BaseARTMAP.BaseARTMAP] :value: [] .. py:attribute:: is_supervised :type: Optional[bool] :value: None .. py:method:: get_params(deep: bool = True) -> dict Get parameters for this estimator. :param deep: If True, will return the parameters for this class and contained subobjects that are estimators. :type deep: bool, optional, default=True :returns: Parameter names mapped to their values. :rtype: dict .. py:method:: set_params(**params) Set the parameters of this estimator. :param \*\*params: Estimator parameters. :type \*\*params: dict :returns: **self** -- The estimator instance. :rtype: DeepARTMAP .. py:property:: labels_ :type: numpy.ndarray Get the labels from the first layer. :returns: The labels from the first ART layer. :rtype: np.ndarray .. py:property:: labels_deep_ :type: numpy.ndarray Get the deep labels from all layers. :returns: Deep labels from all ART layers concatenated together. :rtype: np.ndarray .. py:property:: n_modules :type: int Get the number of ART modules. :returns: The number of ART modules. :rtype: int .. py:property:: n_layers :type: int Get the number of layers. :returns: The number of layers in DeepARTMAP. :rtype: int .. py:method:: map_deep(level: int, y_a: Union[numpy.ndarray, int]) -> Union[numpy.ndarray, int] Map a label from one arbitrary level to the highest (B) level. :param level: The level from which the label is taken. :type level: int :param y_a: The cluster label(s) at the input level. :type y_a: np.ndarray or int :returns: The cluster label(s) at the highest level (B). :rtype: np.ndarray or int .. py:method:: validate_data(X: list[numpy.ndarray], y: Optional[numpy.ndarray] = None) Validate the data before clustering. :param X: The input data sets for each module. :type X: list of np.ndarray :param y: The corresponding labels, by default None. :type y: np.ndarray, optional :raises AssertionError: If the input data is inconsistent or does not match the expected format. .. py:method:: prepare_data(X: Union[numpy.ndarray, list[numpy.ndarray]], y: Optional[numpy.ndarray] = None) -> Union[numpy.ndarray, Tuple[list[numpy.ndarray], Optional[numpy.ndarray]]] Prepare the data for clustering. :param X: The input data set for each module. :type X: list of np.ndarray :param y: The corresponding labels, by default None. :type y: np.ndarray, optional :returns: The prepared data set and labels (if any). :rtype: tuple of (list of np.ndarray, np.ndarray) .. py:method:: restore_data(X: Union[numpy.ndarray, list[numpy.ndarray]], y: Optional[numpy.ndarray] = None) -> Union[numpy.ndarray, Tuple[list[numpy.ndarray], Optional[numpy.ndarray]]] Restore the data to its original state before preparation. :param X: The input data set for each module. :type X: list of np.ndarray :param y: The corresponding labels, by default None. :type y: np.ndarray, optional :returns: The restored data set and labels (if any). :rtype: tuple of (list of np.ndarray, np.ndarray) .. py:method:: fit(X: list[numpy.ndarray], y: Optional[numpy.ndarray] = None, max_iter=1, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0) Fit the DeepARTMAP model to the data. :param X: The input data sets for each module. :type X: list of np.ndarray :param y: The corresponding labels for supervised learning, by default None. :type y: np.ndarray, optional :param max_iter: The number of iterations to fit the model, by default 1. :type max_iter: int, optional :param match_tracking: The method to reset vigilance if a mismatch occurs, by default "MT+". :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, optional :param epsilon: A small adjustment factor for match tracking, by default 0.0. :type epsilon: float, optional :returns: The fitted DeepARTMAP model. :rtype: DeepARTMAP .. py:method:: partial_fit(X: list[numpy.ndarray], y: Optional[numpy.ndarray] = None, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0) Partially fit the DeepARTMAP model to the data. :param X: The input data sets for each module. :type X: list of np.ndarray :param y: The corresponding labels for supervised learning, by default None. :type y: np.ndarray, optional :param match_tracking: The method to reset vigilance if a mismatch occurs, by default "MT+". :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, optional :param epsilon: A small adjustment factor for match tracking, by default 0.0. :type epsilon: float, optional :returns: The partially fitted DeepARTMAP model. :rtype: DeepARTMAP .. py:method:: predict(X: Union[numpy.ndarray, list[numpy.ndarray]], clip: bool = False) -> list[numpy.ndarray] Predict the labels for the input data. :param X: The input data set for prediction. :type X: np.ndarray or list of np.ndarray :param clip: clip the input values to be between the previously seen data limits :type clip: bool :returns: The predicted labels for each layer. :rtype: list of np.ndarray