Skip to main content

A Python library for Adaptive Resonance Theory (ART) algorithms.

Project description

AdaptiveResonanceLib

Welcome to AdaptiveResonanceLib, a comprehensive and modular Python library for Adaptive Resonance Theory (ART) algorithms. Based on scikit-learn, our library offers a wide range of ART models designed for both researchers and practitioners in the field of machine learning and neural networks. Whether you're working on classification, clustering, or pattern recognition, AdaptiveResonanceLib provides the tools you need to implement ART algorithms efficiently and effectively.

Adaptive Resonance Theory (ART)

Adaptive Resonance Theory (ART) is both

  1. A neuroscientific theory of how the brain balances plasticity (learning new information) with stability (retaining what it already knows), and
  2. A family of machine‑learning algorithms that operationalise this idea for clustering, classification, continual‑learning, and other tasks.

First proposed by Stephen Grossberg and Gail Carpenter in the mid‑1970s , ART models treat learning as an interactive search between bottom‑up evidence and top‑down expectations:

  1. Activation. A new input pattern activates stored memories (categories) in proportion to their similarity to the input.

  2. Candidate selection. The most active memory (call it J) is tentatively chosen to represent the input.

  3. Vigilance check (resonance test). The match between the input and memory J is compared to a user‑chosen threshold (ρ) (the vigilance parameter).

    • If the match ≥ (ρ) → Resonance. The memory and input are deemed compatible; J is updated to incorporate the new information.
    • If the match < (ρ) → Mismatch‑reset. Memory J is temporarily inhibited, and the next best candidate is tested.
    • If no memory passes the test → a new category is created directly from the input.
  4. Output. In clustering mode, the index of the resonant (or newly created) memory is returned as the cluster label.

A step-by-step flow chart depicting the generalized ART algorithm can be found here.

Vigilance

ρ sets an explicit upper bound on how dissimilar two inputs can be while still ending up in the same category:

Vigilance (ρ) Practical effect
( ρ = 0 ) All inputs merge into a single, broad category
Moderate (( 0 < ρ < 1 )) Finer granularity as (ρ) increases
( ρ = 1 ) Every distinct input forms its own category (memorisation)

This single knob lets practitioners trade off specificity against generality without retraining from scratch.

Notable Variants

Variant Input type Task Trait
ART 1 Binary Unsupervised clustering Original model
Fuzzy ART Real‑valued ([0,1]) Unsupervised clustering Uses fuzzy AND operator for analog inputs, resulting in rectagular categories
ARTMAP Paired inputs ((X, y)) Supervised classification Two ART modules linked by an associative map field
Gaussian ART Real‑valued Clustering Replace rectangular category fields with Gaussian ones for smoother decision boundaries
FALCON Paired inputs ((State, Action, Reward)) Reinforcement Learning Uses three ART modules to create a dynamic SARSA grid for solving reinforcement learning tasks

All variants share the same resonance‑test backbone, so you can grasp one and quickly extend to the others.

Strengths and Things to Watch

  • Online / incremental learning – adapts one sample at a time without replay.
  • Explicit category prototypes – easy to inspect and interpret.
  • Built‑in catastrophic‑forgetting control via (ρ).
  • Parameter sensitivity – vigilance (and, in many variants, the learning rate (\beta)) must be tuned to your data.
  • Order dependence – the sequence of inputs can affect category formation; shuffling your training data is recommended for unbiased results.

Available Models

AdaptiveResonanceLib includes implementations for the following ART models:

Comparison of Elementary Models

Comparison of Elementary Images

Installation

To install AdaptiveResonanceLib, simply use pip:

pip install artlib

Or to install directly from the most recent source:

pip install git+https://github.com/NiklasMelton/AdaptiveResonanceLib.git@develop

Ensure you have Python 3.9 or newer installed.

Quick Start

Here are some quick examples to get you started with AdaptiveResonanceLib:

Clustering Data with the Fuzzy ART model

from artlib import FuzzyART
import numpy as np
from tensorflow.keras.datasets import mnist

# Load the MNIST dataset
n_dim = 28*28
(X_train, _), (X_test, _) = mnist.load_data()
X_train = X_train.reshape((-1, n_dim)) # flatten images
X_test = X_test.reshape((-1, n_dim))

# Initialize the Fuzzy ART model
model = FuzzyART(rho=0.7, alpha = 0.0, beta=1.0)

# (Optional) Tell the model the data limits for normalization
lower_bounds = np.array([0.]*n_dim)
upper_bounds = np.array([255.]*n_dim)
model.set_data_bounds(lower_bounds, upper_bounds)

# Prepare Data
train_X_prep = model.prepare_data(X_train)
test_X_prep = model.prepare_data(X_test)

# Fit the model
model.fit(train_X_prep)

# Predict data labels
predictions = model.predict(test_X_prep)

Fitting a Classification Model with SimpleARTMAP

from artlib import GaussianART, SimpleARTMAP
import numpy as np
from tensorflow.keras.datasets import mnist

# Load the MNIST dataset
n_dim = 28*28
(X_train, y_train), (X_test, y_test) = mnist.load_data()
X_train = X_train.reshape((-1, n_dim)) # flatten images
X_test = X_test.reshape((-1, n_dim))

# Initialize the Gaussian ART model
sigma_init = np.array([0.5]*X_train.shape[1]) # variance estimate for each feature
module_a = GaussianART(rho=0.0, sigma_init=sigma_init)

# (Optional) Tell the model the data limits for normalization
lower_bounds = np.array([0.]*n_dim)
upper_bounds = np.array([255.]*n_dim)
module_a.set_data_bounds(lower_bounds, upper_bounds)

# Initialize the SimpleARTMAP model
model = SimpleARTMAP(module_a=module_a)

# Prepare Data
train_X_prep = model.prepare_data(X_train)
test_X_prep = model.prepare_data(X_test)

# Fit the model
model.fit(train_X_prep, y_train)

# Predict data labels
predictions = model.predict(test_X_prep)

Fitting a Regression Model with FusionART

from artlib import FuzzyART, HypersphereART, FusionART
import numpy as np

# Your dataset
X_train = np.array([...]) # shape (n_samples, n_features_X)
y_train = np.array([...]) # shape (n_samples, n_features_y)
test_X = np.array([...])

# Initialize the Fuzzy ART model
module_x = FuzzyART(rho=0.0, alpha = 0.0, beta=1.0)

# Initialize the Hypersphere ART model
r_hat = 0.5*np.sqrt(X_train.shape[1]) # no restriction on hyperpshere size
module_y = HypersphereART(rho=0.0, alpha = 0.0, beta=1.0, r_hat=r_hat)

# Initialize the FusionARTMAP model
gamma_values = [0.5, 0.5] # eqaul weight to both channels
channel_dims = [
  2*X_train.shape[1], # fuzzy ART complement codes data so channel dim is 2*n_features
  y_train.shape[1]
]
model = FusionART(
  modules=[module_x, module_y],
  gamma_values=gamma_values,
  channel_dims=channel_dims
)

# Prepare Data
train_Xy = model.join_channel_data(channel_data=[X_train, y_train])
train_Xy_prep = model.prepare_data(train_Xy)
test_Xy = model.join_channel_data(channel_data=[X_train], skip_channels=[1])
test_Xy_prep = model.prepare_data(test_Xy)

# Fit the model
model.fit(train_Xy_prep)

# Predict y-channel values and clip X values outside previously observed ranges
pred_y = model.predict_regression(test_Xy_prep, target_channels=[1], clip=True)

Data Normalization

AdaptiveResonanceLib models require feature data to be normalized between 0.0 and 1.0 inclusively. This requires identifying the boundaries of the data space.

If the first batch of your training data is representative of the entire data space, you dont need to do anything and artlib will identify the data bounds automatically. However, this will often not be sufficient and the following work-arounds will be needed:

Users can manually set the bounds using the following code snippet or similar:

# Set the boundaries of your data for normalization
lower_bounds = np.array([0.]*n_features)
upper_bounds = np.array([1.]*n_features)
model.set_data_bounds(lower_bounds, upper_bounds)

Or users can present all batches of data to the model for automatic boundary identification:

# Find the boundaries of your data for normalization
all_data = [train_X, test_X]
_, _ = model.find_data_bounds(all_data)

If only the boundaries of your testing data are unknown, you can call model.predict() with clip=True to clip testing data to the bounds seen during training. Only use this if you understand what you are doing.

C++ Optimizations

Most ARTlib classes rely on NumPy / SciPy for linear-algebra routines, but several go further:

Level Accelerated components Implementations
Python (Numba JIT) Activation & vigilance kernels ART1, Fuzzy ART, Binary Fuzzy ART
Native C++ (Pybind11) Entire fit / predict pipelines Fuzzy ARTMAP, Hypersphere ARTMAP, Gaussian ARTMAP, Binary Fuzzy ARTMAP

How the C++ variants work

  1. End-to-end native execution – Training and inference run entirely in C++, eliminating Python-level overhead.
  2. State hand-off – After fitting, the C++ routine exports cluster weights and metadata back to the corresponding pure-Python class. You can therefore: • inspect attributes (weights_, categories_, …) • serialize with pickle • plug them into any downstream ARTlib or scikit-learn pipeline exactly as you would with the Python-only models.
  3. Trade-off – The C++ versions sacrifice some modularity (you cannot swap out internal ART components) in exchange for significantly shorter run-times.

C++ Acceleration Quick reference

Class Acceleration method Primary purpose
ART1 Numba JIT kernels Clustering
Fuzzy ART Numba JIT kernels Clustering
Binary Fuzzy ART Numba JIT kernels Clustering
Fuzzy ARTMAP Full C++ implementation Classification
Hypersphere ARTMAP Full C++ implementation Classification
Gaussian ARTMAP Full C++ implementation Classification
Binary Fuzzy ARTMAP Full C++ implementation Classification

Example Usage

from artlib import FuzzyARTMAP
import numpy as np
from tensorflow.keras.datasets import mnist

# Load the MNIST dataset
n_dim = 28*28
(X_train, y_train), (X_test, y_test) = mnist.load_data()
X_train = X_train.reshape((-1, n_dim)) # flatten images
X_test = X_test.reshape((-1, n_dim))

# Initialize the Fuzzy ART model
model = FuzzyARTMAP(rho=0.7, alpha = 0.0, beta=1.0)

# (Optional) Tell the model the data limits for normalization
lower_bounds = np.array([0.]*n_dim)
upper_bounds = np.array([255.]*n_dim)
model.set_data_bounds(lower_bounds, upper_bounds)

# Prepare Data
train_X_prep = model.prepare_data(X_train)
test_X_prep = model.prepare_data(X_test)

# Fit the model
model.fit(train_X_prep, y_train)

# Predict data labels
predictions = model.predict(test_X_prep)

Timing Comparison

The below figures demonstrate the acceleration seen by the C++ ARTMAP variants in comparison to their baseline Python versions for a 1000 sample subset of the MNIST dataset.

MNIST ART fit times MNIST ART predict times

From the above plots, it becomes apparent that the C++ variants are superior in their runtime performance and should be the default choice of practitioners wishing to work with these specific compound models.

While the current selection remains limited, future releases will expand the native C++ implementation as user demand for them increases.

Documentation

For more detailed documentation, including the full list of parameters for each model, visit our Read the Docs page.

Examples

For examples of how to use each model in AdaptiveResonanceLib, check out the /examples directory in our repository.

Contributing

We welcome contributions to AdaptiveResonanceLib! If you have suggestions for improvements, or if you'd like to add more ART models, please see our CONTRIBUTING.md file for guidelines on how to contribute.

You can also join our Discord server and participate directly in the discussion.

License

AdaptiveResonanceLib is open source and available under the MIT license. See the LICENSE file for more info.

Contact

For questions and support, please open an issue in the GitHub issue tracker or message us on our Discord server. We'll do our best to assist you.

Happy Modeling with AdaptiveResonanceLib!

Citing this Repository

If you use this project in your research, please cite it as:

Melton, N. (2025). AdaptiveResonanceLib (Version 0.1.8)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

artlib-0.1.8.tar.gz (116.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

artlib-0.1.8-cp312-cp312-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.12Windows x86-64

artlib-0.1.8-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (14.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

artlib-0.1.8-cp312-cp312-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

artlib-0.1.8-cp311-cp311-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.11Windows x86-64

artlib-0.1.8-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (14.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

artlib-0.1.8-cp311-cp311-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

artlib-0.1.8-cp310-cp310-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.10Windows x86-64

artlib-0.1.8-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (14.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

artlib-0.1.8-cp310-cp310-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

artlib-0.1.8-cp39-cp39-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.9Windows x86-64

artlib-0.1.8-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (14.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

artlib-0.1.8-cp39-cp39-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file artlib-0.1.8.tar.gz.

File metadata

  • Download URL: artlib-0.1.8.tar.gz
  • Upload date:
  • Size: 116.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for artlib-0.1.8.tar.gz
Algorithm Hash digest
SHA256 c51b7f09fed2cc79118c29913d6f7dc622fe08b6b80569d7e6ed9b58eff14a61
MD5 28a75ed474401beaf40f693b0d6d1726
BLAKE2b-256 6df56e65228b2b90b1da12f0a83cbedba4ba74a01dacd041eb2a962d42f0eb82

See more details on using hashes here.

File details

Details for the file artlib-0.1.8-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: artlib-0.1.8-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for artlib-0.1.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a5bed11fe33de214620214f98ebc2ce4c7d0d7ab8f407b8a8f972ba60b747a39
MD5 053d7a010d51cdd1ce65870d4798a2d1
BLAKE2b-256 6d2b7a773da4f5484b443d4af20414a5c571e6e9d21baf40e38bb1f7e9eaaab6

See more details on using hashes here.

File details

Details for the file artlib-0.1.8-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for artlib-0.1.8-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d763af6c308de46d62258624ca66ac7e4461df3c9c719e5de18c0ca8dd5fc4e5
MD5 47ab773acc6f9b254a13aad11f204852
BLAKE2b-256 39504a010d59ccde2126a8e14cf700ff7be340a05db9d0e36c369e5bbc0f6d1d

See more details on using hashes here.

File details

Details for the file artlib-0.1.8-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for artlib-0.1.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e44cf3851d901f259f0ef35ce8a2ca3325721b3abab6f81c49c4578119096fad
MD5 77a8a698c39f27a3f337ef9bcd196b93
BLAKE2b-256 8a550785d5eaece9a23e040f02dc8b51b32c894c7ab055142c97eebdd4095085

See more details on using hashes here.

File details

Details for the file artlib-0.1.8-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: artlib-0.1.8-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for artlib-0.1.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7f112e1651fc1a56ae05ece5c85846a98f513a30eaac6f25cdf908deea247459
MD5 b3fb87c26e548d05c73499379c77f712
BLAKE2b-256 6863b0e3cf1283764e37b71fe7ba21271872393804f5e8c711b0f81c2592f867

See more details on using hashes here.

File details

Details for the file artlib-0.1.8-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for artlib-0.1.8-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 220d3b2d3413b911161707549572128e4e647219c3c80a513b5e681664b053d6
MD5 2bc170ec52c3ffa38c7758d9ba345a2c
BLAKE2b-256 1a1fad7f09c70f42bf5e2222bc889c4b67da6bf73cbe8c8ca89cb8edb1965def

See more details on using hashes here.

File details

Details for the file artlib-0.1.8-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for artlib-0.1.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 116e2ef4f28b63d66a94e6df0ae47829459d1a875654d5bf4a8bcbc47a050171
MD5 33cf67db5f721d47da49f91c5bcd2699
BLAKE2b-256 6b858f94a7fda5df3413ab395ed69c03a2cee7c7d03b296bb10d7339fb6d03d9

See more details on using hashes here.

File details

Details for the file artlib-0.1.8-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: artlib-0.1.8-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for artlib-0.1.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 663bcb00e10f4af77aa88eed79f8617ec5d36a3f060834f88a14cf298df25a56
MD5 5954a4b91c5cc1129764cac74faad035
BLAKE2b-256 edc41c54789b91af701e36badaf17ce3f3cbc5da4c5a905787c3a2b26ef3b234

See more details on using hashes here.

File details

Details for the file artlib-0.1.8-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for artlib-0.1.8-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 985325ea095019f69adec24f15ed3ea5201f31236c1945dc72178eae67f576af
MD5 5fdbf5773b4ca52fd598bbdada7fa2c6
BLAKE2b-256 0ec52b6ef8d652a4201e811f1aaef22b334a82052ed566fcf7cfe633af0c276b

See more details on using hashes here.

File details

Details for the file artlib-0.1.8-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for artlib-0.1.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 66f6edcbbf8498f790ec8a3c226aeab1df72364bb2290c8887a397f1da69cd90
MD5 fa7053691450ef37cc2e5dda28fb3a37
BLAKE2b-256 25a6f29de21e99b5c18e9dab38413b717786b405ac85739f3f9d30dd237c7795

See more details on using hashes here.

File details

Details for the file artlib-0.1.8-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: artlib-0.1.8-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for artlib-0.1.8-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 cd24bb652bc6e4d201cb8d700309386e420e85b5880d6c6af88b1c0a3e6010a7
MD5 fbbe9d23e50944e155c22ebb6ee776c9
BLAKE2b-256 0503d753814363fbd9919b007e4602df2d29398cc871545e459793a65efb7a23

See more details on using hashes here.

File details

Details for the file artlib-0.1.8-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for artlib-0.1.8-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f0211418eaacdcd2184c542257bcc986d16d6eadd637281b568201cad94057b4
MD5 a8a9d8d1cc5ce8f01900b573f3af3fed
BLAKE2b-256 44884815c535ce125b4b4408949b1482cc7c39200b8ec75059083c8317f67b2c

See more details on using hashes here.

File details

Details for the file artlib-0.1.8-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for artlib-0.1.8-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 942e69e4e8db181e34948ba96a008cf0f8b14c502dbb7b91be1973ac67473c60
MD5 5b73d209e476bc2cb25b9f9000092640
BLAKE2b-256 d5741bcd11439a750413cd553d25d785753c02dfafa108e0d0f9b1c661c6c37b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page