artlib ====== .. py:module:: artlib .. autoapi-nested-parse:: Adaptive Resonance Theory (ART) is a cognitive and neural network model that explains how the brain learns to recognize patterns while maintaining stability in the face of new, potentially conflicting information. ART networks are known for their ability to perform unsupervised learning and adaptively categorize data without forgetting previously learned patterns, a feature known as "plasticity-stability balance.". The ART modules provided here support classification, clustering, and reinforcement learning tasks by dynamically adjusting to incoming data streams. They also offer advanced capabilities, including hierarchical clustering, topological clustering, data fusion, and regression, enabling flexible exploration of complex data structures. `Adaptive Resonance Theory `_ Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/artlib/biclustering/index /autoapi/artlib/common/index /autoapi/artlib/cvi/index /autoapi/artlib/elementary/index /autoapi/artlib/fusion/index /autoapi/artlib/hierarchical/index /autoapi/artlib/optimized/index /autoapi/artlib/reinforcement/index /autoapi/artlib/supervised/index /autoapi/artlib/topological/index Classes ------- .. autoapisummary:: artlib.BaseART artlib.BaseARTMAP artlib.ART1 artlib.ART2A artlib.BayesianART artlib.EllipsoidART artlib.GaussianART artlib.FuzzyART artlib.BinaryFuzzyART artlib.HypersphereART artlib.QuadraticNeuronART artlib.iCVIFuzzyART artlib.CVIART artlib.ARTMAP artlib.SimpleARTMAP artlib.SMART artlib.DeepARTMAP artlib.FusionART artlib.FALCON artlib.TD_FALCON artlib.BARTMAP artlib.TopoART artlib.DualVigilanceART artlib.BinaryFuzzyARTMAP artlib.FuzzyARTMAP artlib.HypersphereARTMAP artlib.GaussianARTMAP Functions --------- .. autoapisummary:: artlib.normalize artlib.complement_code artlib.de_complement_code artlib.de_normalize artlib.VAT Package Contents ---------------- .. py:class:: BaseART(params: Dict) Bases: :py:obj:`sklearn.base.BaseEstimator`, :py:obj:`sklearn.base.ClusterMixin` Generic implementation of Adaptive Resonance Theory (ART) .. py:attribute:: data_format :value: 'default' .. py:attribute:: params .. py:attribute:: sample_counter_ :value: 0 .. py:attribute:: weight_sample_counter_ :type: List[int] :value: [] .. py:attribute:: d_min_ :value: None .. py:attribute:: d_max_ :value: None .. py:attribute:: is_fitted_ :value: False .. py:attribute:: labels_ .. py:method:: __getattr__(key) .. py:method:: __setattr__(key, value) .. py:method:: get_params(deep: bool = True) -> Dict :param deep: If True, will return the parameters for this class and contained subobjects that are estimators. :type deep: bool, default=True :returns: Parameter names mapped to their values. :rtype: dict .. py:method:: set_params(**params) Set the parameters of this estimator. Specific redefinition of `sklearn.BaseEstimator.set_params` for ART classes. :param \*\*params: Estimator parameters. :type \*\*params: dict :returns: **self** -- Estimator instance. :rtype: object .. py:method:: set_data_bounds(lower_bounds: numpy.ndarray, upper_bounds: numpy.ndarray) Manually set the data bounds for normalization. :param lower_bounds: The lower bounds for each column. :type lower_bounds: np.ndarray :param upper_bounds: The upper bounds for each column. :type upper_bounds: np.ndarray .. py:method:: find_data_bounds(*data_batches: list[numpy.ndarray]) -> Tuple[numpy.ndarray, numpy.ndarray] Automatically find the data bounds for normalization from a list of data batches. :param \*data_batches: Batches of data to be presented to the model :type \*data_batches: list[np.ndarray] :returns: Lower and upper bounds for data. :rtype: tuple[np.ndarray, np.ndarray] .. py:method:: prepare_data(X: numpy.ndarray) -> numpy.ndarray Prepare data for clustering. :param X: The dataset. :type X: np.ndarray :returns: Normalized data. :rtype: np.ndarray .. py:method:: restore_data(X: numpy.ndarray) -> numpy.ndarray Restore data to state prior to preparation. :param X: The dataset. :type X: np.ndarray :returns: Restored data. :rtype: np.ndarray .. py:property:: n_clusters :type: int Get the current number of clusters. :returns: The number of clusters. :rtype: int .. py:method:: validate_params(params: Dict) :staticmethod: :abstractmethod: Validate clustering parameters. :param params: Dictionary containing parameters for the algorithm. :type params: dict .. py:method:: check_dimensions(X: numpy.ndarray) Check the data has the correct dimensions. :param X: The dataset. :type X: np.ndarray .. py:method:: validate_data(X: numpy.ndarray) Validates the data prior to clustering. Parameters: - X: data set .. py:method:: category_choice(i: numpy.ndarray, w: numpy.ndarray, params: Dict) -> Tuple[float, Optional[Dict]] :abstractmethod: Get the activation of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: Cluster activation and cache used for later processing. :rtype: tuple .. py:method:: match_criterion(i: numpy.ndarray, w: numpy.ndarray, params: Dict, cache: Optional[Dict] = None) -> Tuple[float, Optional[Dict]] :abstractmethod: Get the match criterion of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: Cluster match criterion and cache used for later processing. :rtype: tuple .. py:method:: match_criterion_bin(i: numpy.ndarray, w: numpy.ndarray, params: Dict, cache: Optional[Dict] = None, op: Callable = operator.ge) -> Tuple[bool, Dict] Get the binary match criterion of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: Binary match criterion and cache used for later processing. :rtype: tuple .. py:method:: update(i: numpy.ndarray, w: numpy.ndarray, params: Dict, cache: Optional[Dict] = None) -> numpy.ndarray :abstractmethod: Get the updated cluster weight. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: Updated cluster weight. :rtype: np.ndarray .. py:method:: new_weight(i: numpy.ndarray, params: Dict) -> numpy.ndarray :abstractmethod: Generate a new cluster weight. :param i: Data sample. :type i: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: Updated cluster weight. :rtype: np.ndarray .. py:method:: add_weight(new_w: numpy.ndarray) Add a new cluster weight. :param new_w: New cluster weight to add. :type new_w: np.ndarray .. py:method:: set_weight(idx: int, new_w: numpy.ndarray) Set the value of a cluster weight. :param idx: Index of cluster to update. :type idx: int :param new_w: New cluster weight. :type new_w: np.ndarray .. py:method:: _match_tracking(cache: Union[List[Dict], Dict], epsilon: float, params: Union[List[Dict], Dict], method: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~']) -> bool Perform match tracking using the specified method. :param cache: Cached match criterion value. :type cache: dict :param epsilon: Small adjustment factor for match tracking. :type epsilon: float :param params: Parameters :type params: dict :param method: Match tracking method to apply. :type method: Literal["MT+", "MT-", "MT0", "MT1", "MT~"] :returns: Whether to continue searching for a match. :rtype: bool .. py:method:: _match_tracking_operator(method: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~']) -> Callable :staticmethod: .. py:method:: _set_params(new_params) .. py:method:: _deep_copy_params() -> Dict .. py:method:: step_fit(x: numpy.ndarray, match_reset_func: Optional[Callable] = None, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0) -> int Fit the model to a single sample. :param x: Data sample. :type x: np.ndarray :param match_reset_func: A callable that influences cluster creation. :type match_reset_func: callable, optional :param match_tracking: Method for resetting match criterion. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, default="MT+" :param epsilon: Epsilon value used for adjusting match criterion. :type epsilon: float, default=0.0 :returns: Cluster label of the input sample. :rtype: int .. py:method:: step_pred(x) -> int Predict the label for a single sample. :param x: Data sample. :type x: np.ndarray :returns: Cluster label of the input sample. :rtype: int .. py:method:: pre_step_fit(X: numpy.ndarray) Undefined function called prior to each sample fit. Useful for cluster pruning. :param X: The dataset. :type X: np.ndarray .. py:method:: post_step_fit(X: numpy.ndarray) Undefined function called after each sample fit. Useful for cluster pruning. :param X: The dataset. :type X: np.ndarray .. py:method:: post_fit(X: numpy.ndarray) Undefined function called after fit. Useful for cluster pruning. :param X: The dataset. :type X: np.ndarray .. py:method:: fit(X: numpy.ndarray, y: Optional[numpy.ndarray] = None, match_reset_func: Optional[Callable] = None, max_iter=1, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0, verbose: bool = False, leave_progress_bar: bool = True) Fit the model to the data. :param X: The dataset. :type X: np.ndarray :param y: Not used. For compatibility. :type y: np.ndarray, optional :param match_reset_func: A callable that influences cluster creation. :type match_reset_func: callable, optional :param max_iter: Number of iterations to fit the model on the same dataset. :type max_iter: int, default=1 :param match_tracking: Method for resetting match criterion. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, default="MT+" :param epsilon: Epsilon value used for adjusting match criterion. :type epsilon: float, default=0.0 :param verbose: If True, displays progress of the fitting process. :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 .. py:method:: partial_fit(X: numpy.ndarray, match_reset_func: Optional[Callable] = None, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0) Iteratively fit the model to the data. :param X: The dataset. :type X: np.ndarray :param match_reset_func: A callable that influences cluster creation. :type match_reset_func: callable, optional :param match_tracking: Method for resetting match criterion. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, default="MT+" :param epsilon: Epsilon value used for adjusting match criterion. :type epsilon: float, default=0.0 .. py:method:: fit_gif(X: numpy.ndarray, y: Optional[numpy.ndarray] = None, match_reset_func: Optional[Callable] = None, max_iter=1, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0, verbose: bool = False, leave_progress_bar: bool = True, ax: Optional[matplotlib.axes.Axes] = None, filename: Optional[str] = None, colors: Optional[artlib.common.utils.IndexableOrKeyable] = None, n_cluster_estimate: int = 20, fps: int = 5, final_hold_secs: float = 0.0, **kwargs) Fit the model to the data and make a gif of the process. :param X: The dataset. :type X: np.ndarray :param y: Not used. For compatibility. :type y: np.ndarray, optional :param match_reset_func: A callable that influences cluster creation. :type match_reset_func: callable, optional :param max_iter: Number of iterations to fit the model on the same dataset. :type max_iter: int, default=1 :param match_tracking: Method for resetting match criterion. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, default="MT+" :param epsilon: Epsilon value used for adjusting match criterion. :type epsilon: float, default=0.0 :param verbose: If True, displays progress of the fitting process. :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 :param ax: Figure axes. :type ax: matplotlib.axes.Axes, optional :param colors: Colors to use for each cluster. :type colors: IndexableOrKeyable, optional :param n_cluster_estimate: estimate of number of clusters. Used for coloring plot. :type n_cluster_estimate: int, default=20 :param fps: gif frames per second :type fps: int, default=5 :param final_hold_secs: seconds to hold the final frame (n_final_frames=ceil(final_hold_secs * fps)) :type final_hold_secs: float, default=0.0 :param \*\*kwargs: see :func: `artlib.common.BaseART.visualize` :type \*\*kwargs: dict .. py:method:: predict(X: numpy.ndarray, clip: bool = False) -> numpy.ndarray Predict labels for the data. :param X: The dataset. :type X: np.ndarray :param clip: clip the input values to be between the previously seen data limits :type clip: bool :returns: Labels for the data. :rtype: np.ndarray .. py:method:: shrink_clusters(shrink_ratio: float = 0.1) Shrink the clusters by a specified ratio. :param shrink_ratio: The ratio by which to shrink the clusters. Must be between 0 and 1. Default is 0.1. :type shrink_ratio: float, optional :returns: **self** -- Returns the instance with shrunken clusters. :rtype: object .. py:method:: plot_cluster_bounds(ax: matplotlib.axes.Axes, colors: artlib.common.utils.IndexableOrKeyable, linewidth: int = 1) :abstractmethod: Undefined function for visualizing the bounds of each cluster. :param ax: Figure axes. :type ax: matplotlib.axes.Axes :param colors: Colors to use for each cluster. :type colors: IndexableOrKeyable :param linewidth: Width of boundary line. :type linewidth: int, default=1 .. py:method:: get_cluster_centers() -> List[numpy.ndarray] :abstractmethod: Undefined function for getting centers of each cluster. Used for regression. :returns: Cluster centroids. :rtype: list of np.ndarray .. py:method:: visualize(X: numpy.ndarray, y: numpy.ndarray, ax: Optional[matplotlib.axes.Axes] = None, marker_size: int = 10, linewidth: int = 1, colors: Optional[artlib.common.utils.IndexableOrKeyable] = None) Visualize the clustering of the data. :param X: The dataset. :type X: np.ndarray :param y: Sample labels. :type y: np.ndarray :param ax: Figure axes. :type ax: matplotlib.axes.Axes, optional :param marker_size: Size used for data points. :type marker_size: int, default=10 :param linewidth: Width of boundary line. :type linewidth: int, default=1 :param colors: Colors to use for each cluster. :type colors: IndexableOrKeyable, optional .. py:class:: BaseARTMAP Bases: :py:obj:`sklearn.base.BaseEstimator`, :py:obj:`sklearn.base.ClassifierMixin`, :py:obj:`sklearn.base.ClusterMixin` Generic implementation of Adaptive Resonance Theory MAP (ARTMAP) .. py:attribute:: map :type: dict[int, int] .. py:method:: set_params(**params) Set the parameters of this estimator. Specific redefinition of `sklearn.BaseEstimator.set_params` for ARTMAP classes. :param \*\*params: Estimator parameters. :type \*\*params: dict :returns: **self** -- Estimator instance. :rtype: object .. py:method:: map_a2b(y_a: Union[numpy.ndarray, int]) -> Union[numpy.ndarray, int] Map an a-side label to a b-side label. :param y_a: Side A label(s). :type y_a: Union[np.ndarray, int] :returns: Side B cluster label(s). :rtype: Union[np.ndarray, int] .. py:method:: validate_data(X: numpy.ndarray, y: numpy.ndarray) :abstractmethod: Validate the data prior to clustering. :param X: Dataset A. :type X: np.ndarray :param y: Dataset B. :type y: 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) :abstractmethod: Fit the model to the data. :param X: Dataset A. :type X: np.ndarray :param y: Dataset B. :type y: np.ndarray :param max_iter: Number of iterations to fit the model on the same dataset. :type max_iter: int, optional :param match_tracking: Method for resetting match criterion. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, optional :param epsilon: Epsilon value used for adjusting match criterion, by default 1e-10. :type epsilon: float, optional .. py:method:: partial_fit(X: numpy.ndarray, y: numpy.ndarray, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 1e-10) :abstractmethod: Partial fit the model to the data. :param X: Dataset A. :type X: np.ndarray :param y: Dataset B. :type y: np.ndarray :param match_tracking: Method for resetting match criterion. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, optional :param epsilon: Epsilon value used for adjusting match criterion, by default 1e-10. :type epsilon: float, optional .. py:method:: predict(X: numpy.ndarray, clip: bool = False) -> numpy.ndarray :abstractmethod: Predict labels for the data. :param X: Dataset A. :type X: np.ndarray :param clip: clip the input values to be between the previously seen data limits :type clip: bool :returns: B-side labels for the data. :rtype: np.ndarray .. py:method:: predict_ab(X: numpy.ndarray, clip: bool = False) -> tuple[numpy.ndarray, numpy.ndarray] :abstractmethod: Predict labels for the data, both A-side and B-side. :param X: Dataset A. :type X: np.ndarray :param clip: clip the input values to be between the previously seen data limits :type clip: bool :returns: A-side labels for the data, B-side labels for the data. :rtype: tuple[np.ndarray, np.ndarray] .. py:method:: plot_cluster_bounds(ax: matplotlib.axes.Axes, colors: artlib.common.utils.IndexableOrKeyable, linewidth: int = 1) :abstractmethod: Visualize the bounds of each cluster. :param ax: Figure axes. :type ax: matplotlib.axes.Axes :param colors: Colors to use for each cluster. :type colors: IndexableOrKeyable :param linewidth: Width of boundary line, by default 1. :type linewidth: int, optional .. py:method:: visualize(X: numpy.ndarray, y: numpy.ndarray, ax: Optional[matplotlib.axes.Axes] = None, marker_size: int = 10, linewidth: int = 1, colors: Optional[artlib.common.utils.IndexableOrKeyable] = None) :abstractmethod: Visualize the clustering of the data. :param X: Dataset. :type X: np.ndarray :param y: Sample labels. :type y: np.ndarray :param ax: Figure axes, by default None. :type ax: matplotlib.axes.Axes, optional :param marker_size: Size used for data points, by default 10. :type marker_size: int, optional :param linewidth: Width of boundary line, by default 1. :type linewidth: int, optional :param colors: Colors to use for each cluster, by default None. :type colors: IndexableOrKeyable, optional .. py:function:: normalize(data: numpy.ndarray, d_max: Optional[numpy.ndarray] = None, d_min: Optional[numpy.ndarray] = None) -> Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray] Normalize data column-wise between 0 and 1. :param data: 2D array of dataset (rows = samples, columns = features). :type data: np.ndarray :param d_max: Maximum values for each column. :type d_max: np.ndarray, optional :param d_min: Minimum values for each column. :type d_min: np.ndarray, optional :returns: * *np.ndarray* -- Normalized data. * *np.ndarray* -- Maximum values for each column. * *np.ndarray* -- Minimum values for each column. .. py:function:: complement_code(data: numpy.ndarray) -> numpy.ndarray Complement code the data. :param data: Dataset. :type data: np.ndarray :returns: complement coded data. :rtype: np.ndarray .. py:function:: de_complement_code(data: numpy.ndarray) -> numpy.ndarray Find the centroid of complement coded data. :param data: Dataset. :type data: np.ndarray :returns: De-complement coded data. :rtype: np.ndarray .. py:function:: de_normalize(data: numpy.ndarray, d_max: numpy.ndarray, d_min: numpy.ndarray) -> numpy.ndarray Restore column-wise normalized data to original scale. :param data: Normalized data. :type data: np.ndarray :param d_max: Maximum values for each column. :type d_max: np.ndarray :param d_min: Minimum values for each column. :type d_min: np.ndarray :returns: De-normalized data. :rtype: np.ndarray .. py:function:: VAT(data: numpy.ndarray, distance_metric: Optional[Callable] = lambda X: pdist(X, 'euclidean')) -> Tuple[numpy.ndarray, numpy.ndarray] Visual Assessment of Cluster Tendency (VAT) algorithm. VAT was originally designed as a visualization tool for clustering behavior of data. When the VAT-reordered distance matrix is plotted as an image, clusters will appear in visually distinct groups along the diagonal. However, it has since been discovered that the reordering significantly improves the results of order-dependent clustering methods like ART. It is therefore recommended to pre-process data with VAT prior to presentation when possible. .. # Bezdek, J. C., & Hathaway, R. J. (2002). .. # VAT: A tool for visual assessment of cluster tendency. .. # Proceedings of the 2002 International Joint Conference on Neural Networks. .. # doi:10.1109/IJCNN.2002.1007487 .. bibliography:: ../../references.bib :filter: citation_key == "bezdek2002vat" :param data: Input dataset as a 2D numpy array where each row is a sample. :type data: np.ndarray :param distance_metric: Callable function to calculate pairwise distances. Defaults to Euclidean distance using `pdist`. If None, assumes data is a pre-computed distance matrix. :type distance_metric: callable, optional :returns: - Reordered distance matrix reflecting cluster structure. - Reordered list of indices indicating the optimal clustering order. :rtype: Tuple[np.ndarray, np.ndarray] .. py:class:: ART1(rho: float, L: float) Bases: :py:obj:`artlib.common.BaseART.BaseART` ART1 for Binary Clustering. This module implements ART1 as first published in: :cite:`carpenter1987massively`. .. # Carpenter, G. A., & Grossberg, S. (1987a). .. # A massively parallel architecture for a self-organizing neural pattern .. # recognition machine. .. # Computer Vision, Graphics, and Image .. # Processing, 37, 54 – 115. doi:10. 1016/S0734-189X(87)80014-2. ART1 is exclusively for clustering binary data. .. py:method:: prepare_data(X: numpy.ndarray) -> numpy.ndarray Prepare data for clustering. :param X: Dataset. :type X: np.ndarray :returns: Normalized and complement coded data. :rtype: np.ndarray .. py:method:: restore_data(X: numpy.ndarray) -> numpy.ndarray Restore data to its state prior to preparation. :param X: Dataset. :type X: np.ndarray :returns: Restored data. :rtype: np.ndarray .. py:method:: validate_params(params: dict) :staticmethod: Validate clustering parameters. :param params: Dictionary containing parameters for the algorithm. :type params: dict .. py:method:: validate_data(X: numpy.ndarray) Validate the data prior to clustering. :param X: The dataset. :type X: np.ndarray .. py:method:: category_choice(i: numpy.ndarray, w: numpy.ndarray, params: dict) -> tuple[float, Optional[dict]] Get the activation of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: * *float* -- Cluster activation. * *dict, optional* -- Cache used for later processing. .. py:method:: match_criterion(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> Tuple[float, Optional[Dict]] Get the match criterion of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: * *float* -- Cluster match criterion. * *dict* -- Cache used for later processing. .. py:method:: update(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> numpy.ndarray Get the updated cluster weight. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: Updated cluster weight. :rtype: np.ndarray .. py:method:: new_weight(i: numpy.ndarray, params: dict) -> numpy.ndarray Generate a new cluster weight. :param i: Data sample. :type i: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: Updated cluster weight. :rtype: np.ndarray .. py:method:: get_cluster_centers() -> List[numpy.ndarray] Get the centers of each cluster, used for regression. :returns: Cluster centroids. :rtype: list of np.ndarray .. py:class:: ART2A(rho: float, alpha: float, beta: float) Bases: :py:obj:`artlib.common.BaseART.BaseART` ART2-A for Clustering. This module implements ART2-A as first published in: :cite:`carpenter1987art`, :cite:`carpenter1991art` .. # Carpenter, G. A., & Grossberg, S. (1987b). .. # ART 2: self-organization of stable category recognition codes for analog input .. # patterns. .. # Appl. Opt., 26, 4919–4930. doi:10.1364/AO.26.004919. .. # Carpenter, G. A., Grossberg, S., & Rosen, D. B. (1991b). .. # ART 2-A: An adaptive resonance algorithm for rapid category learning and .. # recognition. .. # Neural Networks, 4, 493 – 504. doi:10.1016/0893-6080(91) 90045-7. ART2-A is similar to :class:`~artlib.elementary.ART1.ART1` but designed for analog data. This method is implemented for historical purposes and is not recommended for use. .. py:method:: validate_params(params: dict) :staticmethod: Validate clustering parameters. :param params: Dictionary containing parameters for the algorithm. :type params: dict .. py:method:: check_dimensions(X: numpy.ndarray) Check that the data has the correct dimensions. :param X: The dataset. :type X: np.ndarray .. py:method:: category_choice(i: numpy.ndarray, w: numpy.ndarray, params: dict) -> tuple[float, Optional[dict]] Get the activation of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: * *float* -- Cluster activation. * *dict, optional* -- Cache used for later processing. .. py:method:: match_criterion(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> tuple[float, Optional[dict]] Get the match criterion of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: * *float* -- Cluster match criterion. * *dict* -- Cache used for later processing. .. py:method:: update(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> numpy.ndarray Get the updated cluster weight. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: Updated cluster weight. :rtype: np.ndarray .. py:method:: new_weight(i: numpy.ndarray, params: dict) -> numpy.ndarray Generate a new cluster weight. :param i: Data sample. :type i: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: Updated cluster weight. :rtype: np.ndarray .. py:method:: get_cluster_centers() -> List[numpy.ndarray] Get the centers of each cluster, used for regression. :returns: Cluster centroids. :rtype: list of np.ndarray .. py:class:: BayesianART(rho: float, cov_init: numpy.ndarray) Bases: :py:obj:`artlib.common.BaseART.BaseART` Bayesian ART for Clustering. This module implements Bayesian ART as first published in: :cite:`vigdor2007bayesian`. .. # Vigdor, B., & Lerner, B. (2007). .. # The Bayesian ARTMAP. .. # IEEE Transactions on Neural .. # Networks, 18, 1628–1644. doi:10.1109/TNN.2007.900234. Bayesian ART clusters data in Bayesian Distributions (Hyper-ellipsoids) and is similar to :class:`~artlib.elementary.GaussianART.GaussianART` but differs in that it allows arbitrary rotation of the hyper-ellipsoid. .. py:attribute:: pi2 .. py:method:: validate_params(params: dict) :staticmethod: Validate clustering parameters. :param params: Dictionary containing parameters for the algorithm. :type params: dict .. py:method:: check_dimensions(X: numpy.ndarray) Check that the data has the correct dimensions. :param X: The dataset. :type X: np.ndarray .. py:method:: category_choice(i: numpy.ndarray, w: numpy.ndarray, params: dict) -> tuple[float, Optional[dict]] Get the activation of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: * *float* -- Cluster activation. * *dict, optional* -- Cache used for later processing. .. py:method:: match_criterion(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> Tuple[float, Optional[Dict]] Get the match criterion of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: * *float* -- Cluster match criterion. * *dict* -- Cache used for later processing. .. py:method:: match_criterion_bin(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None, op: Callable = operator.ge) -> tuple[bool, dict] Get the binary match criterion of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :param op: Operator for comparison, by default operator.ge. :type op: callable, optional :returns: * *bool* -- Binary match criterion. * *dict* -- Cache used for later processing. .. py:method:: _match_tracking(cache: Union[List[Dict], Dict], epsilon: float, params: Union[List[Dict], Dict], method: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~']) -> bool Adjust match tracking based on the method and epsilon value. :param cache: Cache containing intermediate results, including the match criterion. :type cache: dict :param epsilon: Adjustment factor for the match criterion. :type epsilon: float :param params: Dictionary containing algorithm parameters. :type params: dict :param method: Match tracking method to use. :type method: {"MT+", "MT-", "MT0", "MT1", "MT~"} :returns: True if match tracking continues, False otherwise. :rtype: bool .. py:method:: update(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> numpy.ndarray Get the updated cluster weight. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: Updated cluster weight. :rtype: np.ndarray .. py:method:: new_weight(i: numpy.ndarray, params: dict) -> numpy.ndarray Generate a new cluster weight. :param i: Data sample. :type i: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: Updated cluster weight. :rtype: np.ndarray .. py:method:: get_cluster_centers() -> List[numpy.ndarray] Get the centers of each cluster, used for regression. :returns: Cluster centroids. :rtype: list of np.ndarray .. py:method:: plot_cluster_bounds(ax: matplotlib.axes.Axes, colors: Iterable, linewidth: int = 1) Visualize the bounds of each cluster. :param ax: Figure axes. :type ax: matplotlib.axes.Axes :param colors: Colors to use for each cluster. :type colors: IndexableOrKeyable :param linewidth: Width of boundary line, by default 1. :type linewidth: int, optional .. py:class:: EllipsoidART(rho: float, alpha: float, beta: float, mu: float, r_hat: float) Bases: :py:obj:`artlib.common.BaseART.BaseART` Ellipsoid ART for Clustering. This module implements Ellipsoid ART as first published in: :cite:`anagnostopoulos2001a`, :cite:`anagnostopoulos2001b`. .. # Anagnostopoulos, G. C., & Georgiopoulos, M. (2001a). .. # Ellipsoid ART and ARTMAP for incremental clustering and classification. .. # In Proc. IEEE International Joint Conference on Neural Networks (IJCNN) .. # (pp. 1221–1226). volume 2. doi:10.1109/IJCNN.2001.939535. .. # Anagnostopoulos, G. C., & Georgiopoulos, M. (2001b). .. # Ellipsoid ART and ARTMAP for incremental unsupervised and supervised learning. .. # In Aerospace/Defense Sensing, Simulation, and Controls (pp. 293– 304). .. # International Society for Optics and Photonics. doi:10.1117/12.421180. Ellipsoid ART clusters data in Hyper-ellipsoids. It is highly sensitive to sample presentation order as the second sample will determine the orientation of the principal axes. .. py:method:: validate_params(params: dict) :staticmethod: Validate clustering parameters. :param params: Dictionary containing parameters for the algorithm. :type params: dict .. py:method:: category_distance(i: numpy.ndarray, centroid: numpy.ndarray, major_axis: numpy.ndarray, params: dict) -> float :staticmethod: Calculate the distance between a sample and the cluster centroid. :param i: Data sample. :type i: np.ndarray :param centroid: Centroid of the cluster. :type centroid: np.ndarray :param major_axis: Major axis of the cluster. :type major_axis: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: Distance between the sample and the cluster centroid. :rtype: float .. py:method:: category_choice(i: numpy.ndarray, w: numpy.ndarray, params: dict) -> tuple[float, Optional[dict]] Get the activation of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: * *float* -- Cluster activation. * *dict, optional* -- Cache used for later processing. .. py:method:: match_criterion(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> Tuple[float, Optional[Dict]] Get the match criterion of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: * *float* -- Cluster match criterion. * *dict* -- Cache used for later processing. .. py:method:: update(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> numpy.ndarray Get the updated cluster weight. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: Updated cluster weight. :rtype: np.ndarray .. py:method:: new_weight(i: numpy.ndarray, params: dict) -> numpy.ndarray Generate a new cluster weight. :param i: Data sample. :type i: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: New cluster weight. :rtype: np.ndarray .. py:method:: get_2d_ellipsoids() -> List[Tuple[numpy.ndarray, float, float, float]] Get the 2D ellipsoids for visualization. :returns: Each tuple contains the centroid, width, height, and angle of an ellipsoid. :rtype: list of tuple .. py:method:: get_cluster_centers() -> List[numpy.ndarray] Get the centers of each cluster, used for regression. :returns: Cluster centroids. :rtype: list of np.ndarray .. py:method:: plot_cluster_bounds(ax: matplotlib.axes.Axes, colors: artlib.common.utils.IndexableOrKeyable, linewidth: int = 1) Visualize the bounds of each cluster. :param ax: Figure axes. :type ax: matplotlib.axes.Axes :param colors: Colors to use for each cluster. :type colors: IndexableOrKeyable :param linewidth: Width of boundary line, by default 1. :type linewidth: int, optional .. py:class:: GaussianART(rho: float, sigma_init: numpy.ndarray, alpha: float = 1e-10) Bases: :py:obj:`artlib.common.BaseART.BaseART` Gaussian ART for Clustering. This module implements Gaussian ART as first published in: :cite:`williamson1996gaussian`. .. # Williamson, J. R. (1996). .. # Gaussian ARTMAP: A Neural Network for Fast Incremental Learning of Noisy .. # Multidimensional Maps. .. # Neural Networks, 9, 881 – 897. doi:10.1016/0893-6080(95)00115-8. Guassian ART clusters data in Gaussian Distributions (Hyper-ellipsoids) and is similar to :class:`~artlib.elementary.BayesianART.BayesianART` but differs in that the hyper-ellipsoid always have their principal axes square to the coordinate frame. It is also faster than :class:`~artlib.elementary.BayesianART.BayesianART`. .. py:method:: validate_params(params: dict) :staticmethod: Validate clustering parameters. :param params: Dictionary containing parameters for the algorithm. :type params: dict .. py:method:: category_choice(i: numpy.ndarray, w: numpy.ndarray, params: dict) -> tuple[float, Optional[dict]] Get the activation of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: * *float* -- Cluster activation. * *dict, optional* -- Cache used for later processing. .. py:method:: match_criterion(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> Tuple[float, Optional[Dict]] Get the match criterion of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: * *float* -- Cluster match criterion. * *dict* -- Cache used for later processing. .. py:method:: update(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> numpy.ndarray Get the updated cluster weight. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: Updated cluster weight. :rtype: np.ndarray .. py:method:: new_weight(i: numpy.ndarray, params: dict) -> numpy.ndarray Generate a new cluster weight. :param i: Data sample. :type i: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: New cluster weight. :rtype: np.ndarray .. py:method:: get_cluster_centers() -> List[numpy.ndarray] Get the centers of each cluster, used for regression. :returns: Cluster centroids. :rtype: list of np.ndarray .. py:method:: plot_cluster_bounds(ax: matplotlib.axes.Axes, colors: Iterable, linewidth: int = 1) Visualize the bounds of each cluster. :param ax: Figure axes. :type ax: matplotlib.axes.Axes :param colors: Colors to use for each cluster. :type colors: IndexableOrKeyable :param linewidth: Width of boundary line, by default 1. :type linewidth: int, optional .. py:class:: FuzzyART(rho: float, alpha: float, beta: float) Bases: :py:obj:`artlib.common.BaseART.BaseART` Fuzzy ART for Clustering. This module implements Fuzzy ART as first published in: :cite:`carpenter1991fuzzy`. .. # Carpenter, G. A., Grossberg, S., & Rosen, D. B. (1991c). .. # Fuzzy ART: Fast stable learning and categorization of analog patterns by an .. # adaptive resonance system. .. # Neural Networks, 4, 759 – 771. doi:10.1016/0893-6080(91)90056-B. Fuzzy ART is a hyper-box based clustering method that is exceptionally fast and explainable. .. py:method:: prepare_data(X: numpy.ndarray) -> numpy.ndarray Prepare data for clustering. :param X: Dataset. :type X: np.ndarray :returns: Normalized and complement coded data. :rtype: np.ndarray .. py:method:: restore_data(X: numpy.ndarray) -> numpy.ndarray Restore data to its state prior to preparation. :param X: Dataset. :type X: np.ndarray :returns: Restored data. :rtype: np.ndarray .. py:method:: validate_params(params: dict) :staticmethod: Validate clustering parameters. :param params: Dictionary containing parameters for the algorithm. :type params: dict .. py:method:: check_dimensions(X: numpy.ndarray) Check that the data has the correct dimensions. :param X: Dataset. :type X: np.ndarray .. py:method:: validate_data(X: numpy.ndarray) Validate the data prior to clustering. :param X: Dataset. :type X: np.ndarray .. py:method:: category_choice(i: numpy.ndarray, w: numpy.ndarray, params: dict) -> tuple[float, Optional[dict]] Get the activation of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: * *float* -- Cluster activation. * *dict, optional* -- Cache used for later processing. .. py:method:: match_criterion(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> Tuple[float, Optional[Dict]] Get the match criterion of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: * *float* -- Cluster match criterion. * *dict* -- Cache used for later processing. .. py:method:: update(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> numpy.ndarray Get the updated cluster weight. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: Updated cluster weight. :rtype: np.ndarray .. py:method:: new_weight(i: numpy.ndarray, params: dict) -> numpy.ndarray Generate a new cluster weight. :param i: Data sample. :type i: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: New cluster weight. :rtype: np.ndarray .. py:method:: get_bounding_boxes(n: Optional[int] = None) -> List[tuple[list[int], list[int]]] Get the bounding boxes for each cluster. :param n: Dimensions of the bounding box. :type n: int, optional :returns: List of bounding boxes. :rtype: list .. py:method:: get_cluster_centers() -> List[numpy.ndarray] Get the centers of each cluster, used for regression. :returns: Cluster centroids. :rtype: list of np.ndarray .. py:method:: shrink_clusters(shrink_ratio: float = 0.1) Shrink the clusters by adjusting the bounding box. :param shrink_ratio: The ratio by which to shrink the clusters, by default 0.1. :type shrink_ratio: float, optional :returns: Self after shrinking the clusters. :rtype: FuzzyART .. py:method:: plot_cluster_bounds(ax: matplotlib.axes.Axes, colors: Iterable, linewidth: int = 1) Visualize the bounds of each cluster. :param ax: Figure axes. :type ax: matplotlib.axes.Axes :param colors: Colors to use for each cluster. :type colors: IndexableOrKeyable :param linewidth: Width of boundary line, by default 1. :type linewidth: int, optional .. py:class:: BinaryFuzzyART(rho: float) Bases: :py:obj:`artlib.elementary.FuzzyART.FuzzyART` Fuzzy ART optimized for binary input data. .. py:attribute:: w_count_cache :type: List[int] :value: [] .. py:method:: prepare_data(X: numpy.ndarray) -> numpy.ndarray Prepare data for clustering. :param X: Dataset. :type X: np.ndarray :returns: Normalized and complement coded data. :rtype: np.ndarray .. py:method:: restore_data(X: numpy.ndarray) -> numpy.ndarray Restore data to its state prior to preparation. :param X: Dataset. :type X: np.ndarray :returns: Restored data. :rtype: np.ndarray .. py:method:: validate_params(params: dict) :staticmethod: Validate clustering parameters. :param params: Dictionary containing parameters for the algorithm. :type params: dict .. py:method:: validate_data(X: numpy.ndarray) Validate the data prior to clustering. :param X: Dataset. :type X: np.ndarray .. py:method:: category_choice(i: numpy.ndarray, w: numpy.ndarray, params: dict) -> tuple[int, Optional[dict]] Get the activation of the cluster using optimized binary operations. .. py:method:: match_criterion(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> Tuple[float, Optional[Dict]] Get the match criterion using optimized binary operations. .. py:method:: match_criterion_bin(i: numpy.ndarray, w: numpy.ndarray, params: Dict, cache: Optional[Dict] = None, op: Callable = operator.ge) -> Tuple[bool, Dict] Get the binary match criterion of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: Binary match criterion and cache used for later processing. :rtype: tuple .. py:method:: set_weight(idx: int, new_w: numpy.ndarray, cache: Optional[dict] = None) Set the value of a cluster weight. :param idx: Index of cluster to update. :type idx: int :param new_w: New cluster weight. :type new_w: np.ndarray :param cache: cache of values created during training step :type cache: Optional[dict] .. py:method:: update(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> numpy.ndarray Get the updated cluster weight using optimized binary operations. .. py:method:: add_weight(new_w: numpy.ndarray) Add a new cluster weight. :param new_w: New cluster weight to add. :type new_w: np.ndarray .. py:method:: step_pred(x) -> int Predict the label for a single sample. :param x: Data sample. :type x: np.ndarray :returns: Cluster label of the input sample. :rtype: int .. py:method:: _match_tracking_integer(cache: Union[List[Dict], Dict], epsilon: int, params: Union[List[Dict], Dict], method: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~']) -> bool Perform match tracking using the specified method. :param cache: Cached match criterion value. :type cache: dict :param epsilon: Small adjustment factor for match tracking. :type epsilon: float :param params: Parameters :type params: dict :param method: Match tracking method to apply. :type method: Literal["MT+", "MT-", "MT0", "MT1", "MT~"] :returns: Whether to continue searching for a match. :rtype: bool .. py:method:: step_fit(x: numpy.ndarray, match_reset_func: Optional[Callable] = None, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0) -> int Fit the model to a single sample. :param x: Data sample. :type x: np.ndarray :param match_reset_func: A callable that influences cluster creation. :type match_reset_func: callable, optional :param match_tracking: Method for resetting match criterion. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, default="MT+" :param epsilon: Epsilon value used for adjusting match criterion. Rounded up to nearest int :type epsilon: float, default=0.0 :returns: Cluster label of the input sample. :rtype: int .. py:class:: HypersphereART(rho: float, alpha: float, beta: float, r_hat: float) Bases: :py:obj:`artlib.common.BaseART.BaseART` Hypersphere ART for Clustering. This module implements Ellipsoid ART as first published in: :cite:`anagnostopoulos2000hypersphere`. .. # Anagnostopoulos, G. C., & Georgiopulos, M. (2000). .. # Hypersphere ART and ARTMAP for unsupervised and supervised, incremental .. # learning. .. # In Proc. IEEE International Joint Conference on Neural Networks (IJCNN) .. # (pp. 59–64). volume 6. doi:10.1109/IJCNN.2000.859373. Hyperpshere ART clusters data in Hyper-spheres similar to k-means with a dynamic k. .. py:method:: validate_params(params: dict) :staticmethod: Validate clustering parameters. :param params: Dictionary containing parameters for the algorithm. :type params: dict .. py:method:: category_distance(i: numpy.ndarray, centroid: numpy.ndarray, radius: float, params) -> float :staticmethod: Compute the category distance between a data sample and a centroid. :param i: Data sample. :type i: np.ndarray :param centroid: Cluster centroid. :type centroid: np.ndarray :param radius: Cluster radius. :type radius: float :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: Category distance. :rtype: float .. py:method:: category_choice(i: numpy.ndarray, w: numpy.ndarray, params: dict) -> tuple[float, Optional[dict]] Get the activation of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: * *float* -- Cluster activation. * *dict, optional* -- Cache used for later processing. .. py:method:: match_criterion(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> tuple[float, Optional[dict]] Get the match criterion of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: * *float* -- Cluster match criterion. * *dict* -- Cache used for later processing. .. py:method:: update(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> numpy.ndarray Get the updated cluster weight. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: Updated cluster weight. :rtype: np.ndarray .. py:method:: new_weight(i: numpy.ndarray, params: dict) -> numpy.ndarray Generate a new cluster weight. :param i: Data sample. :type i: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: New cluster weight. :rtype: np.ndarray .. py:method:: get_cluster_centers() -> List[numpy.ndarray] Get the centers of each cluster, used for regression. :returns: Cluster centroids. :rtype: list of np.ndarray .. py:method:: plot_cluster_bounds(ax: matplotlib.axes.Axes, colors: Iterable, linewidth: int = 1) Visualize the bounds of each cluster. :param ax: Figure axes. :type ax: matplotlib.axes.Axes :param colors: Colors to use for each cluster. :type colors: IndexableOrKeyable :param linewidth: Width of boundary line, by default 1. :type linewidth: int, optional .. py:class:: QuadraticNeuronART(rho: float, s_init: float, lr_b: float, lr_w: float, lr_s: float) Bases: :py:obj:`artlib.common.BaseART.BaseART` Quadratic Neuron ART for Clustering. This module implements Quadratic Neuron ART as first published in: :cite:`su2001application`, :cite:`su2005new`. .. # Su, M.-C., & Liu, T.-K. (2001). .. # Application of neural networks using quadratic junctions in cluster analysis. .. # Neurocomputing, 37, 165 – 175. doi:10.1016/S0925-2312(00)00343-X. .. # Su, M.-C., & Liu, Y.-C. (2005). .. # A new approach to clustering data with arbitrary shapes. .. # Pattern Recognition, 38, 1887 – 1901. doi:10.1016/j.patcog.2005.04.010. Quadratic Neuron ART clusters data in Hyper-ellipsoid by utilizing a quadratic neural network for activation and resonance. .. py:method:: validate_params(params: dict) :staticmethod: Validate clustering parameters. :param params: Dictionary containing parameters for the algorithm. :type params: dict .. py:method:: category_choice(i: numpy.ndarray, w: numpy.ndarray, params: dict) -> tuple[float, Optional[dict]] Get the activation of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: * *float* -- Cluster activation. * *dict, optional* -- Cache used for later processing. .. py:method:: match_criterion(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> Tuple[float, Optional[Dict]] Get the match criterion of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: * *float* -- Cluster match criterion. * *dict* -- Cache used for later processing. .. py:method:: update(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> numpy.ndarray Get the updated cluster weight. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: Updated cluster weight, cache used for later processing. :rtype: np.ndarray .. py:method:: new_weight(i: numpy.ndarray, params: dict) -> numpy.ndarray Generate a new cluster weight. :param i: Data sample. :type i: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: New cluster weight. :rtype: np.ndarray .. py:method:: get_cluster_centers() -> List[numpy.ndarray] Get the centers of each cluster, used for regression. :returns: Cluster centroids. :rtype: list of np.ndarray .. py:method:: plot_cluster_bounds(ax: matplotlib.axes.Axes, colors: Iterable, linewidth: int = 1) Visualize the bounds of each cluster. :param ax: Figure axes. :type ax: matplotlib.axes.Axes :param colors: Colors to use for each cluster. :type colors: IndexableOrKeyable :param linewidth: Width of boundary line, by default 1. :type linewidth: int, optional .. py:class:: iCVIFuzzyART(rho: float, alpha: float, beta: float, validity: int, offline: bool = True) Bases: :py:obj:`artlib.elementary.FuzzyART.FuzzyART` ICVI Fuzzy Art For Clustering. .. # da Silva, Leonardo Enzo Brito, Nagasharath Rayapati, and Donald C. Wunsch. .. # "iCVI-ARTMAP: using incremental cluster validity indices and adaptive resonance .. # theory reset mechanism to accelerate validation and achieve multiprototype .. # unsupervised representations." .. # IEEE Transactions on Neural Networks and Learning Systems .. # 34.12 (2022): 9757-9770. .. bibliography:: ../../references.bib :filter: citation_key == "da2022icvi" .. py:attribute:: CALINSKIHARABASZ :value: 1 .. py:attribute:: offline :value: True .. py:method:: iCVI_match(x, w, c_, params, cache) Apply iCVI (incremental Cluster Validity Index) matching criteria. :param x: Data sample. :type x: np.ndarray :param w: Cluster weight. :type w: np.ndarray :param c_: Cluster index. :type c_: int :param params: Dictionary containing algorithm parameters. :type params: dict :param cache: Cache used for storing intermediate results. :type cache: dict :returns: True if the new criterion value is better than the previous one, False otherwise. :rtype: bool .. py:method:: fit(X: numpy.ndarray, y: Optional[numpy.ndarray] = None, match_reset_func: Optional[Callable] = None, max_iter=1, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0) Fit the model to the data. :param X: The dataset. :type X: np.ndarray :param y: Not used. For compatibility. :type y: np.ndarray, optional :param match_reset_func: A callable accepting the data sample, a cluster weight, the params dict, and the cache dict. Returns True if the cluster is valid for the sample, False otherwise. :type match_reset_func: callable, optional :param max_iter: Number of iterations to fit the model on the same dataset, by default 1. :type max_iter: int, optional :param match_tracking: Method for resetting match criterion. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, optional :param epsilon: Epsilon value used for adjusting match criterion, by default 0.0. :type epsilon: float, optional .. py:class:: CVIART(base_module: artlib.common.BaseART.BaseART, validity: int) Bases: :py:obj:`artlib.common.BaseART.BaseART` CVI Art Classification. Expanded version of Art that uses Cluster Validity Indicies to help with cluster selection. PBM is not implemented, can be seen here. git.mst.edu/acil-group/CVI-Fuzzy-ART/-/blob/master/PBM_index.m?ref_type=heads Note, the default step_fit function in base ART evaluates the matching function even if the other criteria has failed. This means it could run slower then it would otherwise. .. py:attribute:: CALINSKIHARABASZ :value: 1 .. py:attribute:: DAVIESBOULDIN :value: 2 .. py:attribute:: SILHOUETTE :value: 3 .. py:attribute:: base_module .. py:method:: validate_params(params: dict) Validate clustering parameters. :param params: Dictionary containing parameters for the algorithm. :type params: dict .. py:method:: prepare_data(X: numpy.ndarray) -> numpy.ndarray Prepare data for clustering. :param X: Dataset to be normalized. :type X: np.ndarray :returns: Normalized data. :rtype: np.ndarray .. py:method:: restore_data(X: numpy.ndarray) -> numpy.ndarray Restore data to state prior to preparation. :param X: Dataset to be restored. :type X: np.ndarray :returns: Restored data. :rtype: np.ndarray .. py:property:: W :type: List Get the base module weights. :returns: base module weights :rtype: list of np.ndarray .. py:property:: labels_ :type: numpy.ndarray Get the base module labels. :returns: base module labels :rtype: np.ndarray .. py:method:: CVI_match(x, w, c_, params, extra, cache) Evaluate the cluster validity index (CVI) for a match. :param x: Data sample. :type x: np.ndarray :param w: Cluster weight information. :type w: np.ndarray :param c_: Cluster index. :type c_: int :param params: Parameters for the algorithm. :type params: dict :param extra: Extra information including index and validity type. :type extra: dict :param cache: Cache containing values from previous calculations. :type cache: dict :returns: True if the new validity score improves the clustering, False otherwise. :rtype: bool .. py:method:: _match_tracking(cache: dict, epsilon: float, params: dict, method: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~']) -> bool Adjust the vigilance parameter (rho) based on the match tracking method. :param cache: Cache containing match criterion. :type cache: dict :param epsilon: Epsilon value for adjusting the vigilance parameter. :type epsilon: float :param params: Parameters for the algorithm. :type params: dict :param method: Method for resetting match criterion. :type method: {"MT+", "MT-", "MT0", "MT1", "MT~"} :returns: True if further matching is required, False otherwise. :rtype: bool .. py:method:: _set_params(new_params) .. py:method:: _deep_copy_params() -> dict .. py:method:: fit(X: numpy.ndarray, y: Optional[numpy.ndarray] = None, match_reset_func: Optional[Callable] = None, max_iter=1, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0) Fit the model to the data. :param X: The dataset. :type X: np.ndarray :param y: Not used. For compatibility. :type y: np.ndarray, optional :param match_reset_func: A callable accepting the data sample, a cluster weight, the params dict, and the cache dict. Returns True if the cluster is valid for the sample, False otherwise. :type match_reset_func: callable, optional :param max_iter: Number of iterations to fit the model on the same dataset, by default 1. :type max_iter: int, optional :param match_tracking: Method for resetting match criterion. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, optional :param epsilon: Epsilon value used for adjusting match criterion, by default 0.0. :type epsilon: float, optional .. py:method:: pre_step_fit(X: numpy.ndarray) Preprocessing step before fitting each sample. :param X: The dataset. :type X: np.ndarray .. py:method:: post_step_fit(X: numpy.ndarray) Postprocessing step after fitting each sample. :param X: The dataset. :type X: np.ndarray .. py:method:: step_fit(x: numpy.ndarray, match_reset_func: Optional[Callable] = None, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0) -> int :abstractmethod: Fit the model to a single sample. :param x: Data sample. :type x: np.ndarray :param match_reset_func: A callable accepting the data sample, a cluster weight, the params dict, and the cache dict. Returns True if the cluster is valid for the sample, False otherwise. :type match_reset_func: callable, optional :param match_tracking: Method for resetting match criterion. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, optional :param epsilon: Epsilon value used for adjusting match criterion, by default 0.0. :type epsilon: float, optional :returns: Cluster label of the input sample. :rtype: int .. py:method:: step_pred(x: numpy.ndarray) -> int Predict the label for a single sample. :param x: Data sample. :type x: np.ndarray :returns: Cluster label of the input sample. :rtype: int .. py:method:: get_cluster_centers() -> List[numpy.ndarray] Get the centers of the clusters. :returns: Cluster centroids. :rtype: list of np.ndarray .. py:method:: plot_cluster_bounds(ax: matplotlib.axes.Axes, colors: Iterable, linewidth: int = 1) Plot the boundaries of each cluster. :param ax: Figure axes. :type ax: matplotlib.axes.Axes :param colors: Colors to use for each cluster. :type colors: IndexableOrKeyable :param linewidth: Width of boundary line, by default 1. :type linewidth: int, optional .. 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 .. py:class:: SimpleARTMAP(module_a: artlib.common.BaseART.BaseART) Bases: :py:obj:`artlib.common.BaseARTMAP.BaseARTMAP` 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:attribute:: module_a .. py:method:: match_reset_func(i: numpy.ndarray, w: numpy.ndarray, cluster_a, params: dict, extra: dict, cache: Optional[dict] = None) -> bool Permits external factors to influence cluster creation. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight / info. :type w: np.ndarray :param cluster_a: A-side cluster label. :type cluster_a: int :param params: Parameters for the algorithm. :type params: dict :param extra: Additional parameters, including "cluster_b". :type extra: dict :param cache: Values cached from previous calculations. :type cache: dict, optional :returns: True if the match is permitted, False otherwise. :rtype: bool .. py:method:: get_params(deep: bool = True) -> dict Get parameters of the model. :param deep: If True, will return the parameters for this class and contained subobjects that are estimators. :type deep: bool, default=True :returns: Parameter names mapped to their values. :rtype: dict .. py:method:: validate_data(X: numpy.ndarray, y: numpy.ndarray) -> tuple[numpy.ndarray, numpy.ndarray] Validate data prior to clustering. :param X: Data set A. :type X: np.ndarray :param y: Data set B. :type y: np.ndarray :returns: The validated datasets X and y. :rtype: tuple[np.ndarray, 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. :param X: Data set. :type X: np.ndarray :param y: Data set B. Not used in SimpleARTMAP :type y: Optional[np.ndarray] :returns: Prepared data. :rtype: 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 state prior to preparation. :param X: Data set. :type X: np.ndarray :returns: Restored data. :rtype: np.ndarray .. py:method:: step_fit(x: numpy.ndarray, c_b: int, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 1e-10) -> int Fit the model to a single sample. :param x: Data sample for side A. :type x: np.ndarray :param c_b: Side B label. :type c_b: int :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: Side A cluster label. :rtype: int .. 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 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: 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** -- The fitted model. :rtype: SimpleARTMAP .. py:method:: fit_predict(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 model to the data and return the labels. Need to define this or ClusterMixin could cause issues. :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: 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: The labels (same as y). :rtype: np.ndarray .. py:method:: fit_gif(X: numpy.ndarray, y: numpy.ndarray, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 1e-10, verbose: bool = False, leave_progress_bar: bool = True, ax: Optional[matplotlib.axes.Axes] = None, filename: Optional[str] = None, fps: int = 5, final_hold_secs: float = 0.0, colors: Optional[artlib.common.utils.IndexableOrKeyable] = None, n_class_estimate: Optional[int] = None, max_iter: int = 1, **kwargs) Fit the model while recording the learning process as an animated GIF. The routine iterates over the training data, calling :py:meth:`step_fit` for each sample, and captures intermediate plots by repeatedly invoking :py:meth:`visualize`. All frames are written to a GIF file (via ``matplotlib.animation.PillowWriter``), allowing an intuitive, frame‑by‑frame view of how clusters form and adjust over time. :param X: Independent‑channel samples (side A), shape ``(n_samples, n_features)``. :type X: np.ndarray :param y: Target labels (side B), shape ``(n_samples,)``. :type y: np.ndarray :param match_tracking: Strategy used by the ART module to reset its match criterion. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, default="MT+" :param epsilon: Small positive constant added to the vigilance when ``match_tracking`` triggers a reset. :type epsilon: float, default=1e‑10 :param verbose: If ``True``, displays a tqdm progress bar for each epoch. :type verbose: bool, default=False :param leave_progress_bar: If ``True``, leaves the progress bar visible after completion (only relevant when ``verbose`` is ``True``). :type leave_progress_bar: bool, default=True :param ax: Existing axes on which to draw frames. If ``None``, a new figure and axes are created. :type ax: matplotlib.axes.Axes, optional :param filename: Output path for the GIF. Defaults to ``"fit_gif_supervised_.gif"`` if ``None``. :type filename: str, optional :param fps: Frames per second in the resulting GIF. :type fps: int, default=5 :param final_hold_secs: Extra seconds to hold the final frame (duplicates the last plot ``ceil(final_hold_secs * fps)`` times). :type final_hold_secs: float, default=0.0 :param colors: Sequence of colors to use for each class when plotting. If ``None``, a rainbow colormap is generated. :type colors: array‑like, optional :param n_class_estimate: Expected number of distinct classes. Only used when ``colors`` is ``None`` to size the autogenerated colormap. :type n_class_estimate: int, optional :param max_iter: Number of complete passes over ``(X, y)``. :type max_iter: int, default=1 :param \*\*kwargs: Additional keyword arguments forwarded to :py:meth:`visualize` (e.g., ``marker_size``, ``linewidth``). :returns: **self** -- The fitted estimator (identical object, returned for chaining). :rtype: SimpleARTMAP .. rubric:: Notes * Generates a GIF file as a **side‑effect**. The estimator itself is updated exactly as in :py:meth:`fit`; only plotting calls and file I/O are added. * For reproducible colors across different runs, supply an explicit ``colors`` array rather than relying on the rainbow colormap. .. 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:property:: labels_a :type: numpy.ndarray Get labels from side A (module A). :returns: Labels from module A. :rtype: np.ndarray .. py:property:: labels_b :type: numpy.ndarray Get labels from side B. :returns: Labels from side B. :rtype: np.ndarray .. py:property:: labels_ab :type: Dict[str, numpy.ndarray] Get labels from both A-side and B-side. :returns: A dictionary with keys "A" and "B" containing labels from sides A and B, respectively. :rtype: dict .. py:property:: n_clusters :type: int Get the number of clusters in side A. :returns: Number of clusters. :rtype: int .. py:property:: n_clusters_a :type: int Get the number of clusters in side A. :returns: Number of clusters in side A. :rtype: int .. py:property:: n_clusters_b :type: int Get the number of clusters in side B. :returns: Number of clusters in side B. :rtype: int .. py:method:: step_pred(x: numpy.ndarray) -> tuple[int, int] Predict the label for a single sample. :param x: Data sample for side A. :type x: np.ndarray :returns: Side A cluster label, side B cluster label. :rtype: tuple[int, int] .. 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] .. py:method:: plot_cluster_bounds(ax: matplotlib.axes.Axes, colors: artlib.common.utils.IndexableOrKeyable, linewidth: int = 1) Visualize the cluster boundaries. :param ax: Figure axes. :type ax: Axes :param colors: Colors to use for each cluster. :type colors: IndexableOrKeyable :param linewidth: Width of boundary lines. :type linewidth: int, default=1 .. py:method:: visualize(X: numpy.ndarray, y: numpy.ndarray, ax: Optional[matplotlib.axes.Axes] = None, marker_size: int = 10, linewidth: int = 1, colors: Optional[artlib.common.utils.IndexableOrKeyable] = None) Visualize the clustering of the data. :param X: Data set. :type X: np.ndarray :param y: Sample labels. :type y: np.ndarray :param ax: Figure axes. :type ax: Optional[Axes], default=None :param marker_size: Size used for data points. :type marker_size: int, default=10 :param linewidth: Width of boundary lines. :type linewidth: int, default=1 :param colors: Colors to use for each cluster. :type colors: Optional[Iterable], default=None .. py:class:: SMART(base_ART_class: Type, rho_values: Union[list[float], numpy.ndarray], base_params: dict, **kwargs) Bases: :py:obj:`artlib.hierarchical.DeepARTMAP.DeepARTMAP` SMART for Hierachical Clustering. This module implements SMART as first published in: :cite:`bartfai1994hierarchical` .. # Bartfai, G. (1994). .. # Hierarchical clustering with ART neural networks. .. # In Proc. IEEE International Conference on Neural Networks (ICNN) .. # (pp. 940–944). volume 2. .. # doi:10.1109/ICNN.1994.374307. SMART accepts an uninstantiated :class:`~artlib.common.BaseART.BaseART` class and hierarchically clusters data in a divisive fashion by using a set of vigilance values that monotonically increase in their restrictiveness. SMART is a special case of :class:`~artlib.hierarchical.DeepARTMAP.DeepARTMAP`, which forms the backbone of this class, where all channels receive the same data. .. py:attribute:: rho_values .. 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 data for clustering. :param X: The dataset to prepare. :type X: np.ndarray :returns: Prepared data. :rtype: 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 data to its original form before preparation. :param X: The dataset to restore. :type X: np.ndarray :returns: Restored data. :rtype: np.ndarray .. py:method:: fit(X: 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 SMART model to the data. :param X: The dataset to fit the model on. :type X: np.ndarray :param y: Not used, present for compatibility. :type y: np.ndarray, optional :param max_iter: The number of iterations to run the model on the data. :type max_iter: int, optional :param match_tracking: The match reset method to use when adjusting vigilance. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, optional :param epsilon: A small value to adjust vigilance during match tracking. :type epsilon: float, optional :returns: Fitted SMART model. :rtype: SMART .. py:method:: partial_fit(X: numpy.ndarray, y: Optional[numpy.ndarray] = None, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0) Partial fit the SMART model to the data. :param X: The dataset to partially fit the model on. :type X: np.ndarray :param y: Not used, present for compatibility. :type y: np.ndarray, optional :param match_tracking: The match reset method to use when adjusting vigilance. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, optional :param epsilon: A small value to adjust vigilance during match tracking. :type epsilon: float, optional :returns: Partially fitted SMART model. :rtype: SMART .. py:method:: plot_cluster_bounds(ax: matplotlib.axes.Axes, colors: artlib.common.utils.IndexableOrKeyable, linewidth: int = 1) Visualize the cluster boundaries. :param ax: The matplotlib axes on which to plot the cluster boundaries. :type ax: Axes :param colors: The colors to use for each cluster. :type colors: IndexableOrKeyable :param linewidth: The width of the boundary lines. :type linewidth: int, optional :rtype: None .. py:method:: visualize(X: numpy.ndarray, y: numpy.ndarray, ax: Optional[matplotlib.axes.Axes] = None, marker_size: int = 10, linewidth: int = 1, colors: Optional[artlib.common.utils.IndexableOrKeyable] = None) Visualize the clustering of the data with cluster boundaries. :param X: The dataset to visualize. :type X: np.ndarray :param y: The cluster labels for the data points. :type y: np.ndarray :param ax: The matplotlib axes on which to plot the visualization. :type ax: Axes, optional :param marker_size: The size of the data points in the plot. :type marker_size: int, optional :param linewidth: The width of the cluster boundary lines. :type linewidth: int, optional :param colors: The colors to use for each cluster. :type colors: IndexableOrKeyable, optional :rtype: None .. 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 .. py:class:: FusionART(modules: List[artlib.common.BaseART.BaseART], gamma_values: Union[List[float], numpy.ndarray], channel_dims: Union[List[int], numpy.ndarray]) Bases: :py:obj:`artlib.common.BaseART.BaseART` Fusion ART for Data Fusion and Regression. This module implements Fusion ART as first described in: :cite:`tan2007intelligence`. .. # Tan, A.-H., Carpenter, G. A., & Grossberg, S. (2007). .. # Intelligence Through Interaction: Towards a Unified Theory for Learning. .. # In D. Liu, S. Fei, Z.-G. Hou, H. Zhang, & C. Sun (Eds.), .. # Advances in Neural Networks – ISNN 2007 (pp. 1094–1103). .. # Berlin, Heidelberg: Springer Berlin Heidelberg. .. # doi:10.1007/ 978-3-540-72383-7_128. Fusion ART accepts an arbitrary number of ART modules, each assigned a different data channel. The activation and match functions for all ART modules are then fused such that all modules must be simultaneously active and resonant in order for a match to occur. This provides fine-grain control when clustering multi-channel or multi-modal data and allows for different geometries of clusters to be used for each channel. Fusion ART also allows for fitting regression models and specific functions have been implemented to allow this. .. py:attribute:: modules .. py:attribute:: n .. py:attribute:: channel_dims .. py:attribute:: _channel_indices :value: [] .. py:attribute:: dim_ .. py:method:: get_params(deep: bool = True) -> Dict Get the parameters of the FusionART model. :param deep: If True, will return parameters for this class and the contained sub-objects that are estimators (default is True). :type deep: bool, optional :returns: Parameter names mapped to their values. :rtype: dict .. py:property:: n_clusters :type: int Return the number of clusters in the first ART module. :returns: The number of clusters. :rtype: int .. py:property:: W Get the weights of all modules as a single array. :returns: Concatenated weights of all channels from the ART modules. :rtype: list .. py:method:: validate_params(params: Dict) :staticmethod: Validate clustering parameters. :param params: The parameters for the FusionART model. :type params: dict .. py:method:: validate_data(X: numpy.ndarray) Validate the input data for clustering. :param X: The input dataset. :type X: np.ndarray .. py:method:: check_dimensions(X: numpy.ndarray) Ensure that the input data has the correct dimensions. :param X: The input dataset. :type X: np.ndarray .. py:method:: prepare_data(channel_data: List[numpy.ndarray], skip_channels: List[int] = []) -> numpy.ndarray Prepare the input data by processing each channel's data through its respective ART module. :param channel_data: List of arrays, one for each channel. :type channel_data: list of np.ndarray :param skip_channels: Channels to be skipped (default is []). :type skip_channels: list of int, optional :returns: Processed and concatenated data. :rtype: np.ndarray .. py:method:: restore_data(X: numpy.ndarray, skip_channels: List[int] = []) -> List[numpy.ndarray] Restore data to its original state before preparation. :param X: The prepared data. :type X: np.ndarray :param skip_channels: Channels to be skipped (default is []). :type skip_channels: list of int, optional :returns: Restored data for each channel. :rtype: np.ndarray .. py:method:: category_choice(i: numpy.ndarray, w: list, params: Dict, skip_channels: List[int] = []) -> Tuple[float, Optional[Dict]] Get the activation of the cluster. :param i: The data sample. :type i: np.ndarray :param w: The cluster weight information. :type w: np.ndarray :param params: Parameters for the ART algorithm. :type params: dict :param skip_channels: Channels to be skipped (default is []). :type skip_channels: list of int, optional :returns: Cluster activation and cache for further processing. :rtype: tuple .. py:method:: match_criterion(i: numpy.ndarray, w: list, params: Dict, cache: Optional[Dict] = None, skip_channels: List[int] = []) -> Tuple[float, Optional[Dict]] Get the match criterion for the cluster. :param i: The data sample. :type i: np.ndarray :param w: The cluster weight information. :type w: np.ndarray :param params: Parameters for the ART algorithm. :type params: dict :param cache: Cache for previous calculations (default is None). :type cache: dict, optional :param skip_channels: Channels to be skipped (default is []). :type skip_channels: list of int, optional :returns: max match_criterion across channels and the updated cache. :rtype: tuple .. py:method:: match_criterion_bin(i: numpy.ndarray, w: list, params: Dict, cache: Optional[Dict] = None, op: Callable = operator.ge, skip_channels: List[int] = []) -> Tuple[bool, Dict] Get the binary match criterion for the cluster. :param i: The data sample. :type i: np.ndarray :param w: The cluster weight information. :type w: np.ndarray :param params: Parameters for the ART algorithm. :type params: dict :param cache: Cache for previous calculations (default is None). :type cache: dict, optional :param op: Operator for comparison (default is operator.ge). :type op: Callable, optional :param skip_channels: Channels to be skipped (default is []). :type skip_channels: list of int, optional :returns: Binary match criterion and cache for further processing. :rtype: tuple .. py:method:: _match_tracking(cache: Union[List[Dict], Dict], epsilon: float, params: Union[List[Dict], Dict], method: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~']) -> bool Perform match tracking for all channels using the specified method. :param cache: Cached match criterion values for each channel. :type cache: list of dict :param epsilon: Small adjustment factor for match tracking. :type epsilon: float :param params: Parameters for each channel module. :type params: list of dict :param method: Match tracking method to apply. :type method: Literal["MT+", "MT-", "MT0", "MT1", "MT~"] :returns: Whether to continue searching for a match across all channels. :rtype: bool .. py:method:: _set_params(new_params: Dict) Set the parameters for each module in FusionART. :param new_params: A list of parameters for each module. :type new_params: list of dict .. py:method:: _deep_copy_params() -> Dict Create a deep copy of the parameters for each module. :returns: A dictionary with module indices as keys and their deep-copied parameters as values. :rtype: dict .. py:method:: step_fit(x: numpy.ndarray, match_reset_func: Optional[Callable] = None, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0) -> int Fit the model to a single sample. :param x: Data sample. :type x: np.ndarray :param match_reset_func: A callable that influences cluster creation. :type match_reset_func: callable, optional :param match_tracking: Method for resetting match criterion. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, default="MT+" :param epsilon: Epsilon value used for adjusting match criterion. :type epsilon: float, default=0.0 :returns: Cluster label of the input sample. :rtype: int .. py:method:: partial_fit(X: numpy.ndarray, match_reset_func: Optional[Callable] = None, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0) Iteratively fit the model to the data. :param X: Input dataset. :type X: np.ndarray :param match_reset_func: Function to reset the match criteria based on external factors. :type match_reset_func: callable, optional :param match_tracking: Method for resetting match criteria (default is "MT+"). :type match_tracking: Literal["MT+", "MT-", "MT0", "MT1", "MT~"], optional :param epsilon: Value to adjust the vigilance parameter (default is 0.0). :type epsilon: float, optional .. py:method:: step_pred(x, skip_channels: List[int] = []) -> int Predict the label for a single sample. :param x: Input sample. :type x: np.ndarray :param skip_channels: Channels to skip (default is []). :type skip_channels: list of int, optional :returns: Predicted cluster label for the input sample. :rtype: int .. py:method:: predict(X: numpy.ndarray, clip: bool = False, skip_channels: List[int] = []) -> numpy.ndarray Predict labels for the input data. :param X: Input dataset. :type X: np.ndarray :param clip: clip the input values to be between the previously seen data limits :type clip: bool :param skip_channels: Channels to skip (default is []). :type skip_channels: list of int, optional :returns: Predicted labels for the input data. :rtype: np.ndarray .. py:method:: update(i: numpy.ndarray, w: list, params: Dict, cache: Optional[Dict] = None) -> list Update the cluster weight. :param i: Input data sample. :type i: np.ndarray :param w: Cluster weight information. :type w: np.ndarray :param params: Parameters for the ART algorithm. :type params: dict :param cache: Cache for previous calculations (default is None). :type cache: dict, optional :returns: Updated cluster weight. :rtype: list .. py:method:: new_weight(i: numpy.ndarray, params: Dict) -> list Generate a new cluster weight. :param i: Input data sample. :type i: np.ndarray :param params: Parameters for the ART algorithm. :type params: dict :returns: New cluster weight. :rtype: list .. py:method:: add_weight(new_w: list) Add a new cluster weight. Parameters: - new_w: new cluster weight to add .. py:method:: set_weight(idx: int, new_w: list) Set the value of a cluster weight. Parameters: - idx: index of cluster to update - new_w: new cluster weight .. py:method:: get_cluster_centers() -> List[numpy.ndarray] Get the center points for each cluster. :returns: Center points of the clusters. :rtype: list of np.ndarray .. py:method:: get_channel_centers(channel: int) -> List[numpy.ndarray] Get the center points of clusters for a specific channel. :param channel: The channel index. :type channel: int :returns: Cluster centers for the specified channel. :rtype: list of np.ndarray .. py:method:: predict_regression(X: numpy.ndarray, clip: bool = False, target_channels: List[int] = [-1]) -> Union[numpy.ndarray, List[numpy.ndarray]] Predict regression values for the input data using the target channels. :param X: Input dataset. :type X: np.ndarray :param clip: clip the input values to be between the previously seen data limits :type clip: bool :param target_channels: List of target channels to use for regression. If negative values are used, they are considered as channels counting backward from the last channel. By default, it uses the last channel (-1). :type target_channels: list of int, optional :returns: Predicted regression values. If only one target channel is used, returns a single np.ndarray. If multiple target channels are used, returns a list of np.ndarray, one for each channel. :rtype: Union[np.ndarray, list of np.ndarray] .. py:method:: join_channel_data(channel_data: List[numpy.ndarray], skip_channels: List[int] = []) -> numpy.ndarray Concatenate data from different channels into a single array. :param channel_data: Data from each channel. :type channel_data: list of np.ndarray :param skip_channels: Channels to skip (default is []). :type skip_channels: list of int, optional :returns: Concatenated data. :rtype: np.ndarray .. py:method:: split_channel_data(joined_data: numpy.ndarray, skip_channels: List[int] = []) -> List[numpy.ndarray] Split the concatenated data into its original channels. :param joined_data: Concatenated data from multiple channels. :type joined_data: np.ndarray :param skip_channels: Channels to skip (default is []). :type skip_channels: list of int, optional :returns: Split data, one array for each channel. :rtype: list of np.ndarray .. py:class:: FALCON(state_art: artlib.common.BaseART.BaseART, action_art: artlib.common.BaseART.BaseART, reward_art: artlib.common.BaseART.BaseART, gamma_values: Union[List[float], numpy.ndarray] = np.array([0.33, 0.33, 0.34]), channel_dims: Union[List[int], numpy.ndarray] = list[int]) FALCON for Reinforcement Learning. This module implements the reactive FALCON as first described in: :cite:`tan2004falcon`. .. # Tan, A.-H. (2004). .. # FALCON: a fusion architecture for learning, cognition, and navigation. .. # In Proc. IEEE International Joint Conference on Neural Networks (IJCNN) .. # (pp. 3297–3302). volume 4. doi:10.1109/ IJCNN.2004.1381208. FALCON is based on a :class:`~artlib.fusion.FusionART.FusionART` backbone but only accepts 3 channels: State, Action, and Reward. Specific functions are implemented for getting optimal reward and action predictions. .. py:attribute:: fusion_art .. py:method:: prepare_data(states: numpy.ndarray, actions: numpy.ndarray, rewards: numpy.ndarray) -> Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray] Prepare data for clustering. :param states: The state data. :type states: np.ndarray :param actions: The action data. :type actions: np.ndarray :param rewards: The reward data. :type rewards: np.ndarray :returns: Normalized state, action, and reward data. :rtype: tuple of np.ndarray .. py:method:: restore_data(states: numpy.ndarray, actions: numpy.ndarray, rewards: numpy.ndarray) -> Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray] Restore data to its original form before preparation. :param states: The state data. :type states: np.ndarray :param actions: The action data. :type actions: np.ndarray :param rewards: The reward data. :type rewards: np.ndarray :returns: Restored state, action, and reward data. :rtype: tuple of np.ndarray .. py:method:: fit(states: numpy.ndarray, actions: numpy.ndarray, rewards: numpy.ndarray) Fit the FALCON model to the data. :param states: The state data. :type states: np.ndarray :param actions: The action data. :type actions: np.ndarray :param rewards: The reward data. :type rewards: np.ndarray :returns: The fitted FALCON model. :rtype: FALCON .. py:method:: partial_fit(states: numpy.ndarray, actions: numpy.ndarray, rewards: numpy.ndarray) Partially fit the FALCON model to the data. :param states: The state data. :type states: np.ndarray :param actions: The action data. :type actions: np.ndarray :param rewards: The reward data. :type rewards: np.ndarray :returns: The partially fitted FALCON model. :rtype: FALCON .. py:method:: get_actions_and_rewards(state: numpy.ndarray, action_space: Optional[numpy.ndarray] = None) -> Tuple[numpy.ndarray, numpy.ndarray] Get possible actions and their associated rewards for a given state. :param state: The current state. :type state: np.ndarray :param action_space: The available action space, by default None. :type action_space: np.ndarray, optional :returns: The possible actions and their corresponding rewards. :rtype: tuple of np.ndarray .. py:method:: get_action(state: numpy.ndarray, action_space: Optional[numpy.ndarray] = None, optimality: Literal['min', 'max'] = 'max') -> numpy.ndarray Get the best action for a given state based on optimality. :param state: The current state. :type state: np.ndarray :param action_space: The available action space, by default None. :type action_space: np.ndarray, optional :param optimality: Whether to choose the action with the minimum or maximum reward, by default "max". :type optimality: {"min", "max"}, optional :returns: The optimal action. :rtype: np.ndarray .. py:method:: get_probabilistic_action(state: numpy.ndarray, action_space: Optional[numpy.ndarray] = None, offset: float = 0.1, optimality: Literal['min', 'max'] = 'max') -> numpy.ndarray Get a probabilistic action for a given state based on reward distribution. :param state: The current state. :type state: np.ndarray :param action_space: The available action space, by default None. :type action_space: np.ndarray, optional :param offset: The reward offset to adjust probability distribution, by default 0.1. :type offset: float, optional :param optimality: Whether to prefer minimum or maximum rewards, by default "max". :type optimality: {"min", "max"}, optional :returns: The chosen action based on probability. :rtype: np.ndarray .. py:method:: get_rewards(states: numpy.ndarray, actions: numpy.ndarray) -> numpy.ndarray Get the rewards for given states and actions. :param states: The state data. :type states: np.ndarray :param actions: The action data. :type actions: np.ndarray :returns: The rewards corresponding to the given state-action pairs. :rtype: np.ndarray .. py:class:: TD_FALCON(state_art: artlib.common.BaseART.BaseART, action_art: artlib.common.BaseART.BaseART, reward_art: artlib.common.BaseART.BaseART, gamma_values: Union[List[float], numpy.ndarray] = np.array([0.33, 0.33, 0.34]), channel_dims: Union[List[int], numpy.ndarray] = list[int], td_alpha: float = 1.0, td_lambda: float = 1.0) Bases: :py:obj:`FALCON` TD-FALCON for Reinforcement Learning. This module implements TD-FALCON as first described in: :cite:`tan2008integrating`. .. # Tan, A.-H., Lu, N., & Xiao, D. (2008). .. # Integrating Temporal Difference Methods and Self-Organizing Neural Networks for .. # Reinforcement Learning With Delayed Evaluative Feedback. .. # IEEE Transactions on Neural Networks, 19 , 230–244. doi:10.1109/TNN.2007.905839 TD-FALCON is based on a :class:`FALCON` backbone but includes specific function for temporal-difference learning. Currently, only SARSA is implemented and only :class:`~artlib.elementary.FuzzyART.FuzzyART` base modules are supported. .. py:attribute:: td_alpha :value: 1.0 .. py:attribute:: td_lambda :value: 1.0 .. py:method:: fit(states: numpy.ndarray, actions: numpy.ndarray, rewards: numpy.ndarray) :abstractmethod: Fit the TD-FALCON model to the data. :raises NotImplementedError: TD-FALCON can only be trained with partial fit. .. py:method:: calculate_SARSA(states: numpy.ndarray, actions: numpy.ndarray, rewards: numpy.ndarray, single_sample_reward: Optional[float] = None) Calculate the SARSA values for reinforcement learning. :param states: The state data. :type states: np.ndarray :param actions: The action data. :type actions: np.ndarray :param rewards: The reward data. :type rewards: np.ndarray :param single_sample_reward: The reward for a single sample, if applicable, by default None. :type single_sample_reward: float, optional :returns: The state, action, and SARSA-adjusted reward data to be used for fitting. :rtype: tuple of np.ndarray .. py:method:: partial_fit(states: numpy.ndarray, actions: numpy.ndarray, rewards: numpy.ndarray, single_sample_reward: Optional[float] = None) Partially fit the TD-FALCON model using SARSA. :param states: The state data. :type states: np.ndarray :param actions: The action data. :type actions: np.ndarray :param rewards: The reward data. :type rewards: np.ndarray :param single_sample_reward: The reward for a single sample, if applicable, by default None. :type single_sample_reward: float, optional :returns: The partially fitted TD-FALCON model. :rtype: TD_FALCON .. py:class:: BARTMAP(module_a: artlib.common.BaseART.BaseART, module_b: artlib.common.BaseART.BaseART, eta: float) Bases: :py:obj:`sklearn.base.BaseEstimator`, :py:obj:`sklearn.base.BiclusterMixin` BARTMAP for Biclustering. This class implements BARTMAP as first published in: :cite:`xu2011bartmap`. .. # Xu, R., & Wunsch II, D. C. (2011). .. # BARTMAP: A viable structure for biclustering. .. # Neural Networks, 24, 709–716. doi:10.1016/j.neunet.2011.03.020. BARTMAP accepts two instantiated :class:`~artlib.common.BaseART.BaseART` modules `module_a` and `module_b` which cluster the rows (samples) and columns (features) respectively. The features are clustered independently, but the samples are clustered by considering samples already within a row cluster as well as the candidate sample and enforcing a minimum correlation within the subset of features belonging to at least one of the feature clusters. .. py:attribute:: rows_ :type: numpy.ndarray .. py:attribute:: columns_ :type: numpy.ndarray .. py:attribute:: params .. py:attribute:: module_a .. py:attribute:: module_b .. py:method:: __getattr__(key) .. py:method:: __setattr__(key, value) .. py:method:: get_params(deep: bool = True) -> dict Get parameters for this estimator. :param deep: If True, return the parameters for this estimator and contained subobjects that are estimators. :type deep: bool, default=True :returns: Dictionary of parameter names mapped to their values. :rtype: dict .. py:method:: set_params(**params) Set the parameters of this estimator. Specific redefinition of `sklearn.BaseEstimator.set_params` for ART classes. :param \*\*params: Estimator parameters as keyword arguments. :type \*\*params: dict :returns: **self** -- The estimator instance. :rtype: object .. py:method:: validate_params(params: dict) :staticmethod: Validate clustering parameters. :param params: Dictionary containing parameters for the algorithm. :type params: dict .. py:property:: column_labels_ :type: numpy.ndarray Cluster labels for the columns. :returns: **column_labels_** -- Array of cluster labels assigned to each column. :rtype: ndarray of shape (n_columns,) .. py:property:: row_labels_ :type: numpy.ndarray Cluster labels for the rows. :returns: **row_labels_** -- Array of cluster labels assigned to each row. :rtype: ndarray of shape (n_rows,) .. py:property:: n_row_clusters :type: int Number of row clusters. :returns: **n_row_clusters** -- The number of clusters for the rows. :rtype: int .. py:property:: n_column_clusters :type: int Number of column clusters. :returns: **n_column_clusters** -- The number of clusters for the columns. :rtype: int .. py:method:: _get_x_cb(x: numpy.ndarray, c_b: int) Get the components of a vector belonging to a b-side cluster. :param x: A sample vector. :type x: np.ndarray :param c_b: The b-side cluster label. :type c_b: int :returns: The sample vector `x` filtered to include only features belonging to the b-side cluster `c_b`. :rtype: np.ndarray .. py:method:: _pearsonr(a: numpy.ndarray, b: numpy.ndarray) -> float :staticmethod: Get the Pearson correlation between two vectors. :param a: A vector. :type a: np.ndarray :param b: Another vector. :type b: np.ndarray :returns: The Pearson correlation between the two vectors `a` and `b`. :rtype: float .. py:method:: _average_pearson_corr(X: numpy.ndarray, k: int, c_b: int) -> float Get the average Pearson correlation for a sample across all features in cluster b. :param X: The dataset A. :type X: np.ndarray :param k: The sample index. :type k: int :param c_b: The b-side cluster to check. :type c_b: int :returns: The average Pearson correlation for the sample at index `k` across all features in cluster `c_b`. :rtype: float .. py:method:: validate_data(X_a: numpy.ndarray, X_b: numpy.ndarray) Validate the data prior to clustering. :param X_a: Dataset A, containing the samples. :type X_a: np.ndarray :param X_b: Dataset B, containing the features. :type X_b: np.ndarray .. py:method:: match_criterion_bin(X: numpy.ndarray, k: int, c_b: int, params: dict) -> bool Get the binary match criterion of the cluster. :param X: The dataset. :type X: np.ndarray :param k: The sample index. :type k: int :param c_b: The b-side cluster to check. :type c_b: int :param params: Dictionary containing parameters for the algorithm. :type params: dict :returns: Binary value indicating whether the cluster match criterion is met. :rtype: bool .. py:method:: match_reset_func(i: numpy.ndarray, w: numpy.ndarray, cluster_a, params: dict, extra: dict, cache: Optional[dict] = None) -> bool Permit external factors to influence cluster creation. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param cluster_a: A-side cluster label. :type cluster_a: int :param params: Dictionary containing parameters for the algorithm. :type params: dict :param extra: Additional parameters for the algorithm. :type extra: dict :param cache: Dictionary containing values cached from previous calculations. :type cache: dict, optional :returns: True if the match is permitted, otherwise False. :rtype: bool .. py:method:: step_fit(X: numpy.ndarray, k: int) -> int Fit the model to a single sample. :param X: The dataset. :type X: np.ndarray :param k: The sample index. :type k: int :returns: The cluster label of the input sample. :rtype: int .. py:method:: fit(X: numpy.ndarray, max_iter=1) Fit the model to the data. :param X: The dataset to fit the model on. :type X: np.ndarray :param max_iter: The number of iterations to fit the model on the same dataset. :type max_iter: int .. py:method:: visualize(cmap: Optional[matplotlib.colors.Colormap] = None) Visualize the clustering of the data. :param cmap: The colormap to use for visualization. :type cmap: matplotlib.colors.Colormap or str .. py:class:: TopoART(base_module: artlib.common.BaseART.BaseART, beta_lower: float, tau: int, phi: int) Bases: :py:obj:`artlib.common.BaseART.BaseART` Topo ART for Topological Clustering. This module implements Topo ART as first published in: :cite:`tscherepanow2010topoart`. .. # Tscherepanow, M. (2010). .. # TopoART: A Topology Learning Hierarchical ART Network. .. # In K. Diamantaras, W. Duch, & L. S. Iliadis (Eds.), .. # Artificial Neural Networks – ICANN 2010 (pp. 157–167). .. # Berlin, Heidelberg: Springer Berlin Heidelberg. .. # doi:10.1007/978-3-642-15825-4_21. Topo ART clusters accepts an instantiated :class:`~artlib.common.BaseART.BaseART` module and generates a topological clustering by recording the first and second resonant cluster relationships in an adjacency matrix. Further, it updates the second resonant cluster with a lower learning rate than the first, providing for a distributed learning model. .. py:attribute:: base_module .. py:attribute:: adjacency .. py:attribute:: _permanent_mask .. py:method:: validate_params(params: dict) :staticmethod: Validate clustering parameters. :param params: A dictionary containing parameters for the algorithm. :type params: dict :raises AssertionError: If the required parameters are not provided or are invalid. .. py:property:: W :type: List[numpy.ndarray] Get the weight matrix of the base module. :returns: The weight matrix of the base ART module. :rtype: list[np.ndarray] .. py:method:: validate_data(X: numpy.ndarray) Validate the data prior to clustering. :param X: The input dataset. :type X: np.ndarray .. py:method:: prepare_data(X: numpy.ndarray) -> numpy.ndarray Prepare data for clustering. :param X: The input dataset. :type X: np.ndarray :returns: Prepared (normalized) data. :rtype: np.ndarray .. py:method:: restore_data(X: numpy.ndarray) -> numpy.ndarray Restore data to the state prior to preparation. :param X: The input dataset. :type X: np.ndarray :returns: Restored data. :rtype: np.ndarray .. py:method:: category_choice(i: numpy.ndarray, w: numpy.ndarray, params: dict) -> tuple[float, Optional[dict]] Get the activation of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Parameters for the algorithm. :type params: dict :returns: Cluster activation and cache used for later processing. :rtype: tuple[float, Optional[dict]] .. py:method:: match_criterion(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> Tuple[float, Optional[Dict]] Get the match criterion of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Parameters for the algorithm. :type params: dict :param cache: Values cached from previous calculations. :type cache: dict, optional :returns: Cluster match criterion and cache used for later processing. :rtype: tuple[float, dict] .. py:method:: match_criterion_bin(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None, op: Callable = operator.ge) -> tuple[bool, dict] Get the binary match criterion of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Parameters for the algorithm. :type params: dict :param cache: Values cached from previous calculations. :type cache: dict, optional :param op: Comparison operator to use for the binary match criterion. :type op: Callable, default=operator.ge :returns: Binary match criterion and cache used for later processing. :rtype: tuple[bool, dict] .. py:method:: update(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> numpy.ndarray Update the cluster weight. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Parameters for the algorithm. :type params: dict :param cache: Values cached from previous calculations. :type cache: dict, optional :returns: Updated cluster weight. :rtype: np.ndarray .. py:method:: new_weight(i: numpy.ndarray, params: dict) -> numpy.ndarray Generate a new cluster weight. :param i: Data sample. :type i: np.ndarray :param params: Parameters for the algorithm. :type params: dict :returns: Newly generated cluster weight. :rtype: np.ndarray .. py:method:: add_weight(new_w: numpy.ndarray) Add a new cluster weight. :param new_w: New cluster weight to add. :type new_w: np.ndarray .. py:method:: prune(X: numpy.ndarray) Prune clusters based on the number of associated samples. :param X: The input dataset. :type X: np.ndarray .. py:method:: post_step_fit(X: numpy.ndarray) Perform post-fit operations, such as cluster pruning, after fitting each sample. :param X: The input dataset. :type X: np.ndarray .. py:method:: _match_tracking(cache: Union[List[Dict], Dict], epsilon: float, params: Union[List[Dict], Dict], method: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~']) -> bool Adjust the vigilance parameter based on match tracking methods. :param cache: Cached values from previous calculations. :type cache: dict :param epsilon: Adjustment factor for the vigilance parameter. :type epsilon: float :param params: Parameters for the algorithm. :type params: dict :param method: Method to use for match tracking. :type method: Literal["MT+", "MT-", "MT0", "MT1", "MT~"] :returns: True if the match tracking continues, False otherwise. :rtype: bool .. py:method:: _set_params(new_params) Set new parameters for the base module. :param new_params: New parameters to set. :type new_params: dict .. py:method:: _deep_copy_params() -> dict Create a deep copy of the parameters. :returns: Deep copy of the parameters. :rtype: dict .. py:method:: step_fit(x: numpy.ndarray, match_reset_func: Optional[Callable] = None, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0) -> int Fit the model to a single sample. :param x: Data sample. :type x: np.ndarray :param match_reset_func: Function to reset the match based on custom criteria. :type match_reset_func: Callable, optional :param match_tracking: Method to reset the match. :type match_tracking: Literal["MT+", "MT-", "MT0", "MT1", "MT~"], default="MT+" :param epsilon: Adjustment factor for vigilance. :type epsilon: float, default=0.0 :returns: Cluster label of the input sample. :rtype: int .. py:method:: get_cluster_centers() -> List[numpy.ndarray] Get the centers of each cluster. :returns: Cluster centroids. :rtype: List[np.ndarray] .. py:method:: plot_cluster_bounds(ax: matplotlib.axes.Axes, colors: artlib.common.utils.IndexableOrKeyable, linewidth: int = 1) Visualize the boundaries of each cluster. :param ax: Figure axes. :type ax: Axes :param colors: Colors to use for each cluster. :type colors: IndexableOrKeyable :param linewidth: Width of boundary lines. :type linewidth: int, default=1 .. py:class:: DualVigilanceART(base_module: artlib.common.BaseART.BaseART, rho_lower_bound: float) Bases: :py:obj:`artlib.common.BaseART.BaseART` Dual Vigilance ART for Clustering. This module implements Dual Vigilance ART as first published in: :cite:`da2019dual`. .. # Brito da Silva, L. E., Elnabarawy, I., & Wunsch II, D. C. (2019). .. # Dual vigilance fuzzy adaptive resonance theory. .. # Neural Networks, 109, 1–5. doi:10.1016/j.neunet.2018.09.015. Dual Vigilance ART allows a :class:`~artlib.common.BaseART.BaseART` module to cluster with both an upper and lower vigilance value. The upper-vigilance value allows the :class:`~artlib.common.BaseART.BaseART` module to cluster normally, however, data is simultaneously clustered using the lower vigilance level to combine multiple base ART categories into a single abstracted category. This permits clusters to be combined to form arbitrary shapes. For example if the :class:`~artlib.common.BaseART.BaseART` module is :class:`~artlib.elementary.FuzzyART.FuzzyART`, a Dual Vigilance Fuzzy ART clustering result would look like a series of hyper-boxes forming an arbitrary geometry. .. py:attribute:: base_module .. py:attribute:: rho_lower_bound .. py:attribute:: map :type: dict[int, int] .. py:method:: prepare_data(X: numpy.ndarray) -> numpy.ndarray Prepare data for clustering. :param X: The dataset. :type X: np.ndarray :returns: Prepared data from the base module. :rtype: np.ndarray .. py:method:: restore_data(X: numpy.ndarray) -> numpy.ndarray Restore data to its state prior to preparation. :param X: The dataset. :type X: np.ndarray :returns: Restored data from the base module. :rtype: np.ndarray .. py:method:: get_params(deep: bool = True) -> dict Get the parameters of the estimator. :param deep: If True, return the parameters for this class and contained subobjects that are estimators, by default True. :type deep: bool, optional :returns: Parameter names mapped to their values. :rtype: dict .. py:property:: n_clusters :type: int Get the current number of clusters. :returns: The number of clusters. :rtype: int .. py:property:: dim_ Get the dimensionality of the data from the base module. :returns: Dimensionality of the data. :rtype: int .. py:property:: labels_ Get the labels from the base module. :returns: Labels for the data. :rtype: np.ndarray .. py:property:: W :type: List Get the weights from the base module. :returns: Weights of the clusters. :rtype: list of np.ndarray .. py:method:: check_dimensions(X: numpy.ndarray) Check that the data has the correct dimensions. :param X: The dataset. :type X: np.ndarray .. py:method:: validate_data(X: numpy.ndarray) Validate the data prior to clustering. :param X: The dataset. :type X: np.ndarray .. py:method:: validate_params(params: dict) :staticmethod: Validate clustering parameters. :param params: Dictionary containing parameters for the algorithm. :type params: dict .. py:method:: _match_tracking(cache: Union[List[Dict], Dict], epsilon: float, params: Union[List[Dict], Dict], method: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~']) -> bool Adjust match tracking based on the method and epsilon value. :param cache: Cache containing intermediate results, including the match criterion. :type cache: dict :param epsilon: Adjustment factor for the match criterion. :type epsilon: float :param params: Dictionary containing algorithm parameters. :type params: dict :param method: Match tracking method to use. :type method: {"MT+", "MT-", "MT0", "MT1", "MT~"} :returns: True if match tracking continues, False otherwise. :rtype: bool .. py:method:: _set_params(new_params) .. py:method:: _deep_copy_params() -> dict .. py:method:: step_fit(x: numpy.ndarray, match_reset_func: Optional[Callable] = None, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0) -> int Fit the model to a single sample. :param x: Data sample. :type x: np.ndarray :param match_reset_func: A callable accepting the data sample, a cluster weight, the params dict, and the cache dict. Returns True if the cluster is valid for the sample, False otherwise. :type match_reset_func: callable, optional :param match_tracking: Method for resetting match criterion, by default "MT+". :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, optional :param epsilon: Epsilon value used for adjusting match criterion, by default 0.0. :type epsilon: float, optional :returns: Cluster label of the input sample. :rtype: int .. py:method:: step_pred(x) -> int Predict the label for a single sample. :param x: Data sample. :type x: np.ndarray :returns: Cluster label of the input sample. :rtype: int .. py:method:: get_cluster_centers() -> List[numpy.ndarray] Get the centers of each cluster, used for regression. :returns: Cluster centroids. :rtype: list of np.ndarray .. py:method:: plot_cluster_bounds(ax: matplotlib.axes.Axes, colors: artlib.common.utils.IndexableOrKeyable, linewidth: int = 1) Visualize the bounds of each cluster. :param ax: Figure axes. :type ax: matplotlib.axes.Axes :param colors: Colors to use for each cluster. :type colors: IndexableOrKeyable :param linewidth: Width of boundary line, by default 1. :type linewidth: int, optional .. py:class:: BinaryFuzzyARTMAP Factory for generating optimized BinaryFuzzyARTMAP models using various backends. .. py:class:: FuzzyARTMAP Factory for generating optimized FuzzyARTMAP models using various backends. .. py:class:: HypersphereARTMAP Factory for generating optimized HypersphereARTMAP models using various backends. .. py:class:: GaussianARTMAP Factory for generating optimized GaussianARTMAP models using various backends.