artlib.topological.TopoART
Topo ART [18].
Classes
Topo ART for Topological Clustering. |
Module Contents
- class artlib.topological.TopoART.TopoART(base_module: artlib.common.BaseART.BaseART, beta_lower: float, tau: int, phi: int)
Bases:
artlib.common.BaseART.BaseARTTopo ART for Topological Clustering.
This module implements Topo ART as first published in: [18].
Topo ART clusters accepts an instantiated
BaseARTmodule 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.- base_module
- adjacency
- _permanent_mask
- static validate_params(params: dict)
Validate clustering parameters.
- Parameters:
params (dict) – A dictionary containing parameters for the algorithm.
- Raises:
AssertionError – If the required parameters are not provided or are invalid.
- property W: List[numpy.ndarray]
Get the weight matrix of the base module.
- Returns:
The weight matrix of the base ART module.
- Return type:
list[np.ndarray]
- validate_data(X: numpy.ndarray)
Validate the data prior to clustering.
- Parameters:
X (np.ndarray) – The input dataset.
- prepare_data(X: numpy.ndarray) numpy.ndarray
Prepare data for clustering.
- Parameters:
X (np.ndarray) – The input dataset.
- Returns:
Prepared (normalized) data.
- Return type:
np.ndarray
- restore_data(X: numpy.ndarray) numpy.ndarray
Restore data to the state prior to preparation.
- Parameters:
X (np.ndarray) – The input dataset.
- Returns:
Restored data.
- Return type:
np.ndarray
- category_choice(i: numpy.ndarray, w: numpy.ndarray, params: dict) tuple[float, dict | None]
Get the activation of the cluster.
- match_criterion(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: dict | None = None) Tuple[float, Dict | None]
Get the match criterion of the cluster.
- Parameters:
- Returns:
Cluster match criterion and cache used for later processing.
- Return type:
- match_criterion_bin(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: dict | None = None, op: Callable = operator.ge) tuple[bool, dict]
Get the binary match criterion of the cluster.
- Parameters:
- Returns:
Binary match criterion and cache used for later processing.
- Return type:
- update(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: dict | None = None) numpy.ndarray
Update the cluster weight.
- new_weight(i: numpy.ndarray, params: dict) numpy.ndarray
Generate a new cluster weight.
- Parameters:
i (np.ndarray) – Data sample.
params (dict) – Parameters for the algorithm.
- Returns:
Newly generated cluster weight.
- Return type:
np.ndarray
- add_weight(new_w: numpy.ndarray)
Add a new cluster weight.
- Parameters:
new_w (np.ndarray) – New cluster weight to add.
- prune(X: numpy.ndarray)
Prune clusters based on the number of associated samples.
- Parameters:
X (np.ndarray) – The input dataset.
- post_step_fit(X: numpy.ndarray)
Perform post-fit operations, such as cluster pruning, after fitting each sample.
- Parameters:
X (np.ndarray) – The input dataset.
- _match_tracking(cache: List[Dict] | Dict, epsilon: float, params: List[Dict] | Dict, method: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~']) bool
Adjust the vigilance parameter based on match tracking methods.
- Parameters:
- Returns:
True if the match tracking continues, False otherwise.
- Return type:
- _set_params(new_params)
Set new parameters for the base module.
- Parameters:
new_params (dict) – New parameters to set.
- _deep_copy_params() dict
Create a deep copy of the parameters.
- Returns:
Deep copy of the parameters.
- Return type:
- 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) – Function to reset the match based on custom criteria.
match_tracking (Literal["MT+", "MT-", "MT0", "MT1", "MT~"], default="MT+") – Method to reset the match.
epsilon (float, default=0.0) – Adjustment factor for vigilance.
- Returns:
Cluster label of the input sample.
- Return type:
- get_cluster_centers() List[numpy.ndarray]
Get the centers of each cluster.
- Returns:
Cluster centroids.
- Return type:
List[np.ndarray]
- plot_cluster_bounds(ax: matplotlib.axes.Axes, colors: artlib.common.utils.IndexableOrKeyable, linewidth: int = 1)
Visualize the boundaries of each cluster.
- Parameters:
ax (Axes) – Figure axes.
colors (IndexableOrKeyable) – Colors to use for each cluster.
linewidth (int, default=1) – Width of boundary lines.