artlib.common package
Module contents
This module implements several functions and classes used across ARTLib as well as some functions like VAT which are useful in a variety of contexts.
Submodules
artlib.common.BaseART module
artlib.common.BaseARTMAP module
artlib.common.VAT module
VAT.
cluster tendency. .. # Proceedings of the 2002 International Joint Conference on Neural Networks. .. # doi:10.1109/IJCNN.2002.1007487
- artlib.common.VAT.VAT(data: ~numpy.ndarray, distance_metric: ~typing.Callable | None = <function <lambda>>) Tuple[ndarray, 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.
- Parameters:
data (np.ndarray) – Input dataset as a 2D numpy array where each row is a sample.
distance_metric (callable, optional) – Callable function to calculate pairwise distances. Defaults to Euclidean distance using pdist. If None, assumes data is a pre-computed distance matrix.
- Returns:
Reordered distance matrix reflecting cluster structure.
Reordered list of indices indicating the optimal clustering order.
- Return type:
Tuple[np.ndarray, np.ndarray]
artlib.common.utils module
artlib.common.visualization module
Collection of visualization utilities.
- artlib.common.visualization.plot_gaussian_contours_covariance(ax: Axes, mean: ndarray, covariance: ndarray, color: ndarray, max_std: int = 2, sigma_steps: float = 0.25, linewidth: int = 1)
Plot concentric ellipses to represent the contours of a 2D Gaussian distribution with fading colors. Accepts a covariance matrix to properly represent the distribution’s orientation and shape.
- Parameters:
ax (matplotlib.axes.Axes) – Matplotlib axis object to plot the ellipses.
mean (np.ndarray) – A numpy array representing the mean (μ) of the distribution.
covariance (np.ndarray) – A 2x2 numpy array representing the covariance matrix of the distribution.
color (np.ndarray) – A 4D numpy array including RGB and alpha channels to specify the color and initial opacity.
max_std (int, optional) – Maximum number of standard deviations to draw contours to, by default 2.
sigma_steps (float, optional) – Step size in standard deviations for each contour, by default 0.25.
linewidth (int, optional) – Width of the boundary line, by default 1.
- artlib.common.visualization.plot_gaussian_contours_fading(ax: Axes, mean: ndarray, std_dev: ndarray, color: ndarray, max_std: int = 2, sigma_steps: float = 0.25, linewidth: int = 1)
Plot concentric ellipses to represent the contours of a 2D Gaussian distribution with fading colors.
- Parameters:
ax (matplotlib.axes.Axes) – Matplotlib axis object to plot the ellipses.
mean (np.ndarray) – A numpy array representing the mean (μ) of the distribution.
std_dev (np.ndarray) – A numpy array representing the standard deviation (σ) of the distribution.
color (np.ndarray) – A 4D numpy array including RGB and alpha channels to specify the color and initial opacity.
max_std (int, optional) – Maximum number of standard deviations to draw contours to, by default 2.
sigma_steps (float, optional) – Step size in standard deviations for each contour, by default 0.25.
linewidth (int, optional) – Width of the boundary line, by default 1.
- artlib.common.visualization.plot_weight_matrix_as_ellipse(ax: Axes, s: float, W: ndarray, mean: ndarray, color: ndarray, linewidth: int = 1)
Plot the transformation of a unit circle by the weight matrix W as an ellipse.
- Parameters:
ax (matplotlib.axes.Axes) – Matplotlib axis object to plot the ellipse.
s (float) – Scalar to scale the weight matrix W.
W (np.ndarray) – 2x2 weight matrix.
mean (np.ndarray) – The center point (x, y) of the ellipse.
color (np.ndarray) – Color of the ellipse.
linewidth (int, optional) – Width of the boundary line, by default 1.