1
1
"""
2
2
adaptive_resonance_theory.py
3
3
4
- This module implements the Adaptive Resonance Theory 1 (ART1) model, a type
5
- of neural network designed for unsupervised learning and clustering of binary
6
- input data. The ART1 algorithm continuously learns to categorize inputs based
7
- on their similarity while preserving previously learned categories. This is
8
- achieved through a vigilance parameter that controls the strictness of
4
+ This module implements the Adaptive Resonance Theory 1 (ART1) model, a type
5
+ of neural network designed for unsupervised learning and clustering of binary
6
+ input data. The ART1 algorithm continuously learns to categorize inputs based
7
+ on their similarity while preserving previously learned categories. This is
8
+ achieved through a vigilance parameter that controls the strictness of
9
9
category matching, allowing for flexible and adaptive clustering.
10
10
11
- ART1 is particularly useful in applications where it is critical to learn new
12
- patterns without forgetting previously learned ones, making it suitable for
11
+ ART1 is particularly useful in applications where it is critical to learn new
12
+ patterns without forgetting previously learned ones, making it suitable for
13
13
real-time data clustering and pattern recognition tasks.
14
14
15
15
References:
16
- 1. Carpenter, G. A., & Grossberg, S. (1987). "A Adaptive Resonance Theory."
17
- In: Neural Networks for Pattern Recognition, Oxford University Press,
18
- pp.
19
- 2. Carpenter, G. A., & Grossberg, S. (1988). "The ART of Adaptive Pattern
20
- Recognition by a Self-Organizing Neural Network." IEEE Transactions on
21
- Neural Networks, 1(2)DOI: 10.1109/TNN.1988.82656
16
+ 1. Carpenter, G. A., & Grossberg, S. (1987). "A Adaptive Resonance Theory."
17
+ In: Neural Networks for Pattern Recognition, Oxford University Press,
18
+ pp. 194–203.
19
+ 2. Carpenter, G. A., & Grossberg, S. (1988). "The ART of Adaptive Pattern
20
+ Recognition by a Self-Organizing Neural Network." IEEE Transactions on
21
+ Neural Networks, 1(2), 115-130. DOI: 10.1109/TNN.1988.82656
22
22
23
23
"""
24
24
@@ -34,7 +34,7 @@ class ART1:
34
34
num_features (int): Number of features in the input data.
35
35
vigilance (float): Threshold for similarity that determines whether
36
36
an input matches an existing cluster.
37
- weights (List[np.ndarray]): List cluster weights representing learned categories.
37
+ weights (List[np.ndarray]): List of cluster weights representing the learned categories.
38
38
"""
39
39
40
40
def __init__ (self , num_features : int , vigilance : float = 0.7 ) -> None :
@@ -55,7 +55,7 @@ def __init__(self, num_features: int, vigilance: float = 0.7) -> None:
55
55
56
56
self .vigilance = vigilance
57
57
self .num_features = num_features
58
- self .weights : List [np .ndarray ] = [] # Type annotation added here
58
+ self .weights : List [np .ndarray ] = [] # Correctly typed list of numpy arrays
59
59
60
60
def _similarity (self , weight_vector : np .ndarray , input_vector : np .ndarray ) -> float :
61
61
"""
@@ -73,7 +73,7 @@ def _similarity(self, weight_vector: np.ndarray, input_vector: np.ndarray) -> fl
73
73
or len (input_vector ) != self .num_features
74
74
):
75
75
raise ValueError (
76
- "Both weight_vector and input_vector must have the same features."
76
+ "Both weight_vector and input_vector must have the same number of features."
77
77
)
78
78
79
79
return np .dot (weight_vector , input_vector ) / self .num_features
@@ -153,7 +153,7 @@ def art1_example() -> None:
153
153
"""
154
154
Example function demonstrating the usage of the ART1 model.
155
155
156
- This function creates a dataset, trains the ART1 model, and prints clusters.
156
+ This function creates a dataset, trains the ART1 model, and prints assigned clusters.
157
157
158
158
Examples:
159
159
>>> art1_example()
0 commit comments