artlib.elementary.ART1

ART1 [1].

Classes

ART1

ART1 for Binary Clustering.

Functions

match_criterion_numba(i, w_td, dim_)

Compute the match criterion for ART1 clustering.

category_choice_numba(i, w_bu)

Compute the category choice activation for ART1.

update_numba(i, w, L, dim_)

Optimized update function for ART1 using Numba.

Module Contents

artlib.elementary.ART1.match_criterion_numba(i, w_td, dim_)

Compute the match criterion for ART1 clustering.

This function calculates the proportion of active features in the input i that match the corresponding features in the top-down weight vector w_td.

Parameters:
  • i (np.ndarray (int32 or uint8)) – Binary or integer input vector representing the data sample.

  • w_td (np.ndarray (uint8)) – Binary top-down weight vector of the cluster.

  • dim (int) – The number of features (dimensions) in the input vector.

Returns:

The match criterion value, computed as the ratio of matching features to the total number of features.

Return type:

float

artlib.elementary.ART1.category_choice_numba(i, w_bu)

Compute the category choice activation for ART1.

This function calculates the category choice value, which represents the strength of association between an input i and a bottom-up weight vector w_bu.

Parameters:
  • i (np.ndarray (int32 or uint8)) – Binary or integer input vector representing the data sample.

  • w_bu (np.ndarray (float32)) – Bottom-up weight vector of the cluster.

Returns:

The activation value, computed as the sum of element-wise multiplications.

Return type:

float

artlib.elementary.ART1.update_numba(i, w, L, dim_)

Optimized update function for ART1 using Numba.

This function updates the cluster weight vector based on the input i, using ART1 learning rules.

Parameters:
  • i (np.ndarray (int32 or uint8)) – Binary or integer input vector.

  • w (np.ndarray (float32)) – Cluster weight vector, containing both bottom-up and top-down weights.

  • L (float) – Uncommitted node bias parameter.

  • dim (int) – Feature dimension.

Returns:

Updated cluster weight vector.

Return type:

np.ndarray

class artlib.elementary.ART1.ART1(rho: float, L: float)

Bases: artlib.common.BaseART.BaseART

ART1 for Binary Clustering.

This module implements ART1 as first published in: [1].

ART1 is exclusively for clustering binary data.

prepare_data(X: numpy.ndarray) numpy.ndarray

Prepare data for clustering.

Parameters:

X (np.ndarray) – Dataset.

Returns:

Normalized and complement coded data.

Return type:

np.ndarray

restore_data(X: numpy.ndarray) numpy.ndarray

Restore data to its state prior to preparation.

Parameters:

X (np.ndarray) – Dataset.

Returns:

Restored data.

Return type:

np.ndarray

static validate_params(params: dict)

Validate clustering parameters.

Parameters:

params (dict) – Dictionary containing parameters for the algorithm.

validate_data(X: numpy.ndarray)

Validate the data prior to clustering.

Parameters:

X (np.ndarray) – The dataset.

category_choice(i: numpy.ndarray, w: numpy.ndarray, params: dict) tuple[float, dict | None]

Get the activation of the cluster.

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

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

  • params (dict) – Dictionary containing parameters for the algorithm.

Returns:

  • float – Cluster activation.

  • dict, optional – Cache used for later processing.

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:
  • i (np.ndarray) – Data sample.

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

  • params (dict) – Dictionary containing parameters for the algorithm.

  • cache (dict, optional) – Cache containing values from previous calculations.

Returns:

  • float – Cluster match criterion.

  • dict – Cache used for later processing.

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

Get the updated cluster weight.

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

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

  • params (dict) – Dictionary containing parameters for the algorithm.

  • cache (dict, optional) – Cache containing values from previous calculations.

Returns:

Updated cluster weight.

Return type:

np.ndarray

new_weight(i: numpy.ndarray, params: dict) numpy.ndarray

Generate a new cluster weight.

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

  • params (dict) – Dictionary containing parameters for the algorithm.

Returns:

Updated cluster weight.

Return type:

np.ndarray

get_cluster_centers() List[numpy.ndarray]

Get the centers of each cluster, used for regression.

Returns:

Cluster centroids.

Return type:

list of np.ndarray