artlib.fusion.FusionART ======================= .. py:module:: artlib.fusion.FusionART .. autoapi-nested-parse:: Fusion ART :cite:`tan2007intelligence`. Classes ------- .. autoapisummary:: artlib.fusion.FusionART.FusionART Functions --------- .. autoapisummary:: artlib.fusion.FusionART.get_channel_position_tuples Module Contents --------------- .. py:function:: get_channel_position_tuples(channel_dims: List[int]) -> List[Tuple[int, int]] Generate the start and end positions for each channel in the input data. :param channel_dims: A list representing the number of dimensions for each channel. :type channel_dims: list of int :returns: A list of tuples where each tuple represents the start and end index for a channel. :rtype: list of tuple of int .. 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