artlib.fusion.FusionART

Fusion ART [15].

Classes

FusionART

Fusion ART for Data Fusion and Regression.

Functions

get_channel_position_tuples(→ List[Tuple[int, int]])

Generate the start and end positions for each channel in the input data.

Module Contents

artlib.fusion.FusionART.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.

Parameters:

channel_dims (list of int) – A list representing the number of dimensions for each channel.

Returns:

A list of tuples where each tuple represents the start and end index for a channel.

Return type:

list of tuple of int

class artlib.fusion.FusionART.FusionART(modules: List[artlib.common.BaseART.BaseART], gamma_values: List[float] | numpy.ndarray, channel_dims: List[int] | numpy.ndarray)

Bases: artlib.common.BaseART.BaseART

Fusion ART for Data Fusion and Regression.

This module implements Fusion ART as first described in: [15].

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.

modules
n
channel_dims
_channel_indices = []
dim_
get_params(deep: bool = True) Dict

Get the parameters of the FusionART model.

Parameters:

deep (bool, optional) – If True, will return parameters for this class and the contained sub-objects that are estimators (default is True).

Returns:

Parameter names mapped to their values.

Return type:

dict

property n_clusters: int

Return the number of clusters in the first ART module.

Returns:

The number of clusters.

Return type:

int

property W

Get the weights of all modules as a single array.

Returns:

Concatenated weights of all channels from the ART modules.

Return type:

list

static validate_params(params: Dict)

Validate clustering parameters.

Parameters:

params (dict) – The parameters for the FusionART model.

validate_data(X: numpy.ndarray)

Validate the input data for clustering.

Parameters:

X (np.ndarray) – The input dataset.

check_dimensions(X: numpy.ndarray)

Ensure that the input data has the correct dimensions.

Parameters:

X (np.ndarray) – The input dataset.

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.

Parameters:
  • channel_data (list of np.ndarray) – List of arrays, one for each channel.

  • skip_channels (list of int, optional) – Channels to be skipped (default is []).

Returns:

Processed and concatenated data.

Return type:

np.ndarray

restore_data(X: numpy.ndarray, skip_channels: List[int] = []) List[numpy.ndarray]

Restore data to its original state before preparation.

Parameters:
  • X (np.ndarray) – The prepared data.

  • skip_channels (list of int, optional) – Channels to be skipped (default is []).

Returns:

Restored data for each channel.

Return type:

np.ndarray

category_choice(i: numpy.ndarray, w: list, params: Dict, skip_channels: List[int] = []) Tuple[float, Dict | None]

Get the activation of the cluster.

Parameters:
  • i (np.ndarray) – The data sample.

  • w (np.ndarray) – The cluster weight information.

  • params (dict) – Parameters for the ART algorithm.

  • skip_channels (list of int, optional) – Channels to be skipped (default is []).

Returns:

Cluster activation and cache for further processing.

Return type:

tuple

match_criterion(i: numpy.ndarray, w: list, params: Dict, cache: Dict | None = None, skip_channels: List[int] = []) Tuple[float, Dict | None]

Get the match criterion for the cluster.

Parameters:
  • i (np.ndarray) – The data sample.

  • w (np.ndarray) – The cluster weight information.

  • params (dict) – Parameters for the ART algorithm.

  • cache (dict, optional) – Cache for previous calculations (default is None).

  • skip_channels (list of int, optional) – Channels to be skipped (default is []).

Returns:

max match_criterion across channels and the updated cache.

Return type:

tuple

match_criterion_bin(i: numpy.ndarray, w: list, params: Dict, cache: Dict | None = None, op: Callable = operator.ge, skip_channels: List[int] = []) Tuple[bool, Dict]

Get the binary match criterion for the cluster.

Parameters:
  • i (np.ndarray) – The data sample.

  • w (np.ndarray) – The cluster weight information.

  • params (dict) – Parameters for the ART algorithm.

  • cache (dict, optional) – Cache for previous calculations (default is None).

  • op (Callable, optional) – Operator for comparison (default is operator.ge).

  • skip_channels (list of int, optional) – Channels to be skipped (default is []).

Returns:

Binary match criterion and cache for further processing.

Return type:

tuple

_match_tracking(cache: List[Dict] | Dict, epsilon: float, params: List[Dict] | Dict, method: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~']) bool

Perform match tracking for all channels using the specified method.

Parameters:
  • cache (list of dict) – Cached match criterion values for each channel.

  • epsilon (float) – Small adjustment factor for match tracking.

  • params (list of dict) – Parameters for each channel module.

  • method (Literal["MT+", "MT-", "MT0", "MT1", "MT~"]) – Match tracking method to apply.

Returns:

Whether to continue searching for a match across all channels.

Return type:

bool

_set_params(new_params: Dict)

Set the parameters for each module in FusionART.

Parameters:

new_params (list of dict) – A list of parameters for each module.

_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.

Return type:

dict

step_fit(x: numpy.ndarray, match_reset_func: Callable | None = None, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0) int

Fit the model to a single sample.

Parameters:
  • x (np.ndarray) – Data sample.

  • match_reset_func (callable, optional) – A callable that influences cluster creation.

  • match_tracking ({"MT+", "MT-", "MT0", "MT1", "MT~"}, default="MT+") – Method for resetting match criterion.

  • epsilon (float, default=0.0) – Epsilon value used for adjusting match criterion.

Returns:

Cluster label of the input sample.

Return type:

int

partial_fit(X: numpy.ndarray, match_reset_func: Callable | None = None, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0)

Iteratively fit the model to the data.

Parameters:
  • X (np.ndarray) – Input dataset.

  • match_reset_func (callable, optional) – Function to reset the match criteria based on external factors.

  • match_tracking (Literal["MT+", "MT-", "MT0", "MT1", "MT~"], optional) – Method for resetting match criteria (default is “MT+”).

  • epsilon (float, optional) – Value to adjust the vigilance parameter (default is 0.0).

step_pred(x, skip_channels: List[int] = []) int

Predict the label for a single sample.

Parameters:
  • x (np.ndarray) – Input sample.

  • skip_channels (list of int, optional) – Channels to skip (default is []).

Returns:

Predicted cluster label for the input sample.

Return type:

int

predict(X: numpy.ndarray, clip: bool = False, skip_channels: List[int] = []) numpy.ndarray

Predict labels for the input data.

Parameters:
  • X (np.ndarray) – Input dataset.

  • clip (bool) – clip the input values to be between the previously seen data limits

  • skip_channels (list of int, optional) – Channels to skip (default is []).

Returns:

Predicted labels for the input data.

Return type:

np.ndarray

update(i: numpy.ndarray, w: list, params: Dict, cache: Dict | None = None) list

Update the cluster weight.

Parameters:
  • i (np.ndarray) – Input data sample.

  • w (np.ndarray) – Cluster weight information.

  • params (dict) – Parameters for the ART algorithm.

  • cache (dict, optional) – Cache for previous calculations (default is None).

Returns:

Updated cluster weight.

Return type:

list

new_weight(i: numpy.ndarray, params: Dict) list

Generate a new cluster weight.

Parameters:
  • i (np.ndarray) – Input data sample.

  • params (dict) – Parameters for the ART algorithm.

Returns:

New cluster weight.

Return type:

list

add_weight(new_w: list)

Add a new cluster weight.

Parameters: - new_w: new cluster weight to add

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

get_cluster_centers() List[numpy.ndarray]

Get the center points for each cluster.

Returns:

Center points of the clusters.

Return type:

list of np.ndarray

get_channel_centers(channel: int) List[numpy.ndarray]

Get the center points of clusters for a specific channel.

Parameters:

channel (int) – The channel index.

Returns:

Cluster centers for the specified channel.

Return type:

list of np.ndarray

predict_regression(X: numpy.ndarray, clip: bool = False, target_channels: List[int] = [-1]) numpy.ndarray | List[numpy.ndarray]

Predict regression values for the input data using the target channels.

Parameters:
  • X (np.ndarray) – Input dataset.

  • clip (bool) – clip the input values to be between the previously seen data limits

  • target_channels (list of int, optional) – 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).

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.

Return type:

Union[np.ndarray, list of np.ndarray]

join_channel_data(channel_data: List[numpy.ndarray], skip_channels: List[int] = []) numpy.ndarray

Concatenate data from different channels into a single array.

Parameters:
  • channel_data (list of np.ndarray) – Data from each channel.

  • skip_channels (list of int, optional) – Channels to skip (default is []).

Returns:

Concatenated data.

Return type:

np.ndarray

split_channel_data(joined_data: numpy.ndarray, skip_channels: List[int] = []) List[numpy.ndarray]

Split the concatenated data into its original channels.

Parameters:
  • joined_data (np.ndarray) – Concatenated data from multiple channels.

  • skip_channels (list of int, optional) – Channels to skip (default is []).

Returns:

Split data, one array for each channel.

Return type:

list of np.ndarray