aisp 0.3.2__py3-none-any.whl → 0.3.21__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aisp/base/mutation.py +2 -2
- aisp/csa/_ai_recognition_sys.py +10 -8
- aisp/ina/_ai_network.py +13 -5
- aisp/nsa/_binary_negative_selection.py +1 -1
- aisp/nsa/_negative_selection.py +4 -4
- aisp/utils/distance.py +4 -4
- aisp/utils/types.py +3 -3
- {aisp-0.3.2.dist-info → aisp-0.3.21.dist-info}/METADATA +1 -1
- {aisp-0.3.2.dist-info → aisp-0.3.21.dist-info}/RECORD +12 -12
- {aisp-0.3.2.dist-info → aisp-0.3.21.dist-info}/WHEEL +0 -0
- {aisp-0.3.2.dist-info → aisp-0.3.21.dist-info}/licenses/LICENSE +0 -0
- {aisp-0.3.2.dist-info → aisp-0.3.21.dist-info}/top_level.txt +0 -0
aisp/base/mutation.py
CHANGED
@@ -122,8 +122,8 @@ def clone_and_mutate_ranged(
|
|
122
122
|
position_mutations = np.random.permutation(n_features)[:n_mutations]
|
123
123
|
for j in range(n_mutations):
|
124
124
|
idx = position_mutations[j]
|
125
|
-
min_limit = bounds[
|
126
|
-
max_limit = bounds[
|
125
|
+
min_limit = bounds[0][idx]
|
126
|
+
max_limit = bounds[1][idx]
|
127
127
|
clone[idx] = np.random.uniform(min_limit, max_limit)
|
128
128
|
clone_set[i] = clone
|
129
129
|
|
aisp/csa/_ai_recognition_sys.py
CHANGED
@@ -111,13 +111,13 @@ class AIRS(BaseAIRS):
|
|
111
111
|
Way to calculate the distance between the detector and the sample:
|
112
112
|
|
113
113
|
* ``'Euclidean'`` ➜ The calculation of the distance is given by the expression:
|
114
|
-
√( (x₁
|
114
|
+
√( (x₁ - x₂)² + (y₁ - y₂)² + ... + (yn - yn)²).
|
115
115
|
|
116
116
|
* ``'minkowski'`` ➜ The calculation of the distance is given by the expression:
|
117
|
-
( |X₁
|
117
|
+
( |X₁ - Y₁|p + |X₂ - Y₂|p + ... + |Xn - Yn|p) ¹/ₚ.
|
118
118
|
|
119
119
|
* ``'manhattan'`` ➜ The calculation of the distance is given by the expression:
|
120
|
-
( |x₁
|
120
|
+
( |x₁ - x₂| + |y₁ - y₂| + ... + |yn - yn|).
|
121
121
|
|
122
122
|
seed : int
|
123
123
|
Seed for the random generation of detector values. Defaults to None.
|
@@ -139,7 +139,7 @@ class AIRS(BaseAIRS):
|
|
139
139
|
|
140
140
|
References
|
141
141
|
----------
|
142
|
-
.. [1] Brabazon, A., O
|
142
|
+
.. [1] Brabazon, A., O'Neill, M., & McGarraghy, S. (2015). Natural Computing Algorithms. In
|
143
143
|
Natural Computing Series. Springer Berlin Heidelberg.
|
144
144
|
https://doi.org/10.1007/978-3-662-43631-8
|
145
145
|
|
@@ -195,6 +195,7 @@ class AIRS(BaseAIRS):
|
|
195
195
|
self.affinity_threshold = 0.0
|
196
196
|
self.classes = []
|
197
197
|
self._bounds: Optional[npt.NDArray[np.float64]] = None
|
198
|
+
self._n_features: Optional[int] = None
|
198
199
|
|
199
200
|
@property
|
200
201
|
def cells_memory(self) -> Optional[Dict[str, list[Cell]]]:
|
@@ -235,6 +236,7 @@ class AIRS(BaseAIRS):
|
|
235
236
|
self._bounds = np.vstack([np.min(X, axis=0), np.max(X, axis=0)])
|
236
237
|
|
237
238
|
self.classes = np.unique(y)
|
239
|
+
self._n_features = X.shape[1]
|
238
240
|
sample_index = self._slice_index_list_by_class(y)
|
239
241
|
progress = tqdm(
|
240
242
|
total=len(y),
|
@@ -330,11 +332,11 @@ class AIRS(BaseAIRS):
|
|
330
332
|
An ndarray of the form ``C`` [``N samples``], containing the predicted classes for
|
331
333
|
``X``. or ``None``: If there are no detectors for the prediction.
|
332
334
|
"""
|
333
|
-
if self._all_class_cell_vectors is None:
|
335
|
+
if self._all_class_cell_vectors is None or self._n_features is None:
|
334
336
|
return None
|
335
337
|
|
336
338
|
super()._check_and_raise_exceptions_predict(
|
337
|
-
X,
|
339
|
+
X, self._n_features, self._feature_type
|
338
340
|
)
|
339
341
|
|
340
342
|
c: list = []
|
@@ -380,7 +382,7 @@ class AIRS(BaseAIRS):
|
|
380
382
|
|
381
383
|
References
|
382
384
|
----------
|
383
|
-
.. [1] Brabazon, A., O
|
385
|
+
.. [1] Brabazon, A., O'Neill, M., & McGarraghy, S. (2015).
|
384
386
|
Natural Computing Algorithms. Natural Computing Series.
|
385
387
|
Springer Berlin Heidelberg. https://doi.org/10.1007/978-3-662-43631-8
|
386
388
|
"""
|
@@ -441,7 +443,7 @@ class AIRS(BaseAIRS):
|
|
441
443
|
distances = pdist(antigens_list, metric="hamming")
|
442
444
|
else:
|
443
445
|
metric_kwargs = {'p': self.p} if self.metric == 'minkowski' else {}
|
444
|
-
distances = pdist(antigens_list, metric=self.metric, **metric_kwargs)
|
446
|
+
distances = pdist(antigens_list, metric=self.metric, **metric_kwargs) # type: ignore
|
445
447
|
|
446
448
|
n = antigens_list.shape[0]
|
447
449
|
sum_affinity = np.sum(1.0 - (distances / (1.0 + distances)))
|
aisp/ina/_ai_network.py
CHANGED
@@ -29,7 +29,7 @@ class AiNet(BaseAiNet):
|
|
29
29
|
clustering and data compression tasks. The aiNet algorithm uses principles from immune
|
30
30
|
network theory, clonal selection, and affinity maturation to compress high-dimensional
|
31
31
|
datasets. [1]_
|
32
|
-
For clustering, the class uses SciPy
|
32
|
+
For clustering, the class uses SciPy's implementation of the **Minimum Spanning Tree**
|
33
33
|
(MST) to remove the most distant nodes and separate the groups. [2]_
|
34
34
|
|
35
35
|
Parameters
|
@@ -58,13 +58,13 @@ class AiNet(BaseAiNet):
|
|
58
58
|
Way to calculate the distance between the detector and the sample:
|
59
59
|
|
60
60
|
* ``'Euclidean'`` ➜ The calculation of the distance is given by the expression:
|
61
|
-
√( (x₁
|
61
|
+
√( (x₁ - x₂)² + (y₁ - y₂)² + ... + (yn - yn)²).
|
62
62
|
|
63
63
|
* ``'minkowski'`` ➜ The calculation of the distance is given by the expression:
|
64
|
-
( |X₁
|
64
|
+
( |X₁ - Y₁|p + |X₂ - Y₂|p + ... + |Xn - Yn|p) ¹/ₚ.
|
65
65
|
|
66
66
|
* ``'manhattan'`` ➜ The calculation of the distance is given by the expression:
|
67
|
-
( |x₁
|
67
|
+
( |x₁ - x₂| + |y₁ - y₂| + ... + |yn - yn|).
|
68
68
|
|
69
69
|
seed : Optional[int]
|
70
70
|
Seed for the random generation of detector values. Defaults to None.
|
@@ -455,7 +455,7 @@ class AiNet(BaseAiNet):
|
|
455
455
|
"""
|
456
456
|
u = np.reshape(u, (1, -1))
|
457
457
|
v = np.atleast_2d(v)
|
458
|
-
distances = cdist(u, v, metric=self.metric, **self._metric_params)[0]
|
458
|
+
distances = cdist(u, v, metric=self.metric, **self._metric_params)[0] # type: ignore
|
459
459
|
|
460
460
|
return 1 - (distances / (1 + distances))
|
461
461
|
|
@@ -523,6 +523,8 @@ class AiNet(BaseAiNet):
|
|
523
523
|
------
|
524
524
|
ValueError
|
525
525
|
If the Minimum Spanning Tree (MST) has not yet been created
|
526
|
+
If Population of antibodies is empty
|
527
|
+
If MST statistics (mean or std) are not available.
|
526
528
|
|
527
529
|
Updates
|
528
530
|
-------
|
@@ -534,6 +536,12 @@ class AiNet(BaseAiNet):
|
|
534
536
|
if self._mst_structure is None:
|
535
537
|
raise ValueError("The Minimum Spanning Tree (MST) has not yet been created.")
|
536
538
|
|
539
|
+
if self._population_antibodies is None or len(self._population_antibodies) == 0:
|
540
|
+
raise ValueError("Population of antibodies is empty")
|
541
|
+
|
542
|
+
if self._mst_mean_distance is None or self._mst_std_distance is None:
|
543
|
+
raise ValueError("MST statistics (mean or std) are not available.")
|
544
|
+
|
537
545
|
if mst_inconsistency_factor is not None:
|
538
546
|
self.mst_inconsistency_factor = mst_inconsistency_factor
|
539
547
|
|
aisp/nsa/_negative_selection.py
CHANGED
@@ -40,11 +40,11 @@ class RNSA(BaseNSA):
|
|
40
40
|
Way to calculate the distance between the detector and the sample:
|
41
41
|
|
42
42
|
+ ``'Euclidean'`` ➜ The calculation of the distance is given by the expression:
|
43
|
-
√( (x₁
|
43
|
+
√( (x₁ - x₂)² + (y₁ - y₂)² + ... + (yn - yn)²).
|
44
44
|
+ ``'minkowski'`` ➜ The calculation of the distance is given by the expression:
|
45
|
-
( |X₁
|
45
|
+
( |X₁ - Y₁|p + |X₂ - Y₂|p + ... + |Xn - Yn|p) ¹/ₚ.
|
46
46
|
+ ``'manhattan'`` ➜ The calculation of the distance is given by the expression:
|
47
|
-
( |x₁
|
47
|
+
( |x₁ - x₂| + |y₁ - y₂| + ... + |yn - yn|) .
|
48
48
|
max_discards : int, default=1000
|
49
49
|
This parameter indicates the maximum number of consecutive detector discards, aimed at
|
50
50
|
preventing a possible infinite loop in case a radius is defined that cannot generate
|
@@ -260,7 +260,7 @@ class RNSA(BaseNSA):
|
|
260
260
|
average_distance[_class_] = np.average(
|
261
261
|
[self.__distance(detector, line) for detector in detectores]
|
262
262
|
)
|
263
|
-
c.append(max(average_distance, key=average_distance.get))
|
263
|
+
c.append(max(average_distance, key=average_distance.get)) # type: ignore
|
264
264
|
return np.array(c)
|
265
265
|
|
266
266
|
def __checks_valid_detector(
|
aisp/utils/distance.py
CHANGED
@@ -40,7 +40,7 @@ def hamming(u: npt.NDArray[np.bool_], v: npt.NDArray[np.bool_]) -> float64:
|
|
40
40
|
def euclidean(u: npt.NDArray[np.float64], v: npt.NDArray[np.float64]) -> float64:
|
41
41
|
"""Calculate the normalized Euclidean distance between two points.
|
42
42
|
|
43
|
-
√( (x₁
|
43
|
+
√( (x₁ - x₂)² + (y₁ - y₂)² + ... + (yn - yn)²)
|
44
44
|
|
45
45
|
Parameters
|
46
46
|
----------
|
@@ -61,7 +61,7 @@ def euclidean(u: npt.NDArray[np.float64], v: npt.NDArray[np.float64]) -> float64
|
|
61
61
|
def cityblock(u: npt.NDArray[float64], v: npt.NDArray[float64]) -> float64:
|
62
62
|
"""Calculate the normalized Manhattan distance between two points.
|
63
63
|
|
64
|
-
(|x₁
|
64
|
+
(|x₁ - x₂| + |y₁ - y₂| + ... + |yn - yn|) / n
|
65
65
|
|
66
66
|
Parameters
|
67
67
|
----------
|
@@ -86,7 +86,7 @@ def cityblock(u: npt.NDArray[float64], v: npt.NDArray[float64]) -> float64:
|
|
86
86
|
def minkowski(u: npt.NDArray[float64], v: npt.NDArray[float64], p: float = 2.0) -> float64:
|
87
87
|
"""Calculate the normalized Minkowski distance between two points.
|
88
88
|
|
89
|
-
(( |X₁
|
89
|
+
(( |X₁ - Y₁|p + |X₂ - Y₂|p + ... + |Xn - Yn|p) ¹/ₚ.) / n
|
90
90
|
|
91
91
|
Parameters
|
92
92
|
----------
|
@@ -124,7 +124,7 @@ def compute_metric_distance(
|
|
124
124
|
u: npt.NDArray[float64],
|
125
125
|
v: npt.NDArray[float64],
|
126
126
|
metric: int,
|
127
|
-
p:
|
127
|
+
p: float = 2.0
|
128
128
|
) -> float64:
|
129
129
|
"""Calculate the distance between two points by the chosen metric.
|
130
130
|
|
aisp/utils/types.py
CHANGED
@@ -12,11 +12,11 @@ FeatureType : Literal["binary-features", "continuous-features", "ranged-features
|
|
12
12
|
MetricType : Literal["manhattan", "minkowski", "euclidean"]
|
13
13
|
Specifies the distance metric to use for calculations. Possible values:
|
14
14
|
- "manhattan": The calculation of the distance is given by the expression:
|
15
|
-
√( (x₁
|
15
|
+
√( (x₁ - x₂)² + (y₁ - y₂)² + ... + (yn - yn)²).
|
16
16
|
- "minkowski": The calculation of the distance is given by the expression:
|
17
|
-
( |X₁
|
17
|
+
( |X₁ - Y₁|p + |X₂ - Y₂|p + ... + |Xn - Yn|p) ¹/ₚ.
|
18
18
|
- "euclidean": The calculation of the distance is given by the expression:
|
19
|
-
( |x₁
|
19
|
+
( |x₁ - x₂| + |y₁ - y₂| + ... + |yn - yn|).
|
20
20
|
"""
|
21
21
|
|
22
22
|
|
@@ -4,28 +4,28 @@ aisp/base/__init__.py,sha256=b-YzeW1iIAEp7JReS6TVzTeBZwFVsfxtOqG9W4gDvdc,211
|
|
4
4
|
aisp/base/_base.py,sha256=uTVh__hQJGe8RCOzCet4ZV3vQbwgj5fXAt4Jdf0x1r0,1792
|
5
5
|
aisp/base/_classifier.py,sha256=xmD7SlPFjdWdrK7dkK8GzLFGOq5w_4jkzK4J-eqHlwA,3375
|
6
6
|
aisp/base/_clusterer.py,sha256=-wzZ4vSI_ZtPvLYryfJ75VaKcp67jxl92lJxfjopVYc,2468
|
7
|
-
aisp/base/mutation.py,sha256=
|
7
|
+
aisp/base/mutation.py,sha256=MJ5BZmJlV2BiECUbo-d4HKJ6MeTI5KuZQqRzevVcF-4,4762
|
8
8
|
aisp/csa/__init__.py,sha256=708jwpqia10bqmh-4-_srwwNuBh7jf2Zix-u8Hfbzmk,348
|
9
|
-
aisp/csa/_ai_recognition_sys.py,sha256=
|
9
|
+
aisp/csa/_ai_recognition_sys.py,sha256=00swgeB2CgpQ4zz2bvuVk50jN7839g9pbb33_9cdsv0,18947
|
10
10
|
aisp/csa/_base.py,sha256=CIj6NDNAH-GCuZpDXAHEWe7jSHUum7mUOnnvXnkEy60,3593
|
11
11
|
aisp/csa/_cell.py,sha256=GUxnzvPyIbBm1YYkMhSx0tcV_oyDhJ7wAo5gtr_1CoY,1845
|
12
12
|
aisp/ina/__init__.py,sha256=cOnxGcxrBdg6lLv2w2sdlToMahKMh_Gw57AfUUPQjMo,329
|
13
|
-
aisp/ina/_ai_network.py,sha256=
|
13
|
+
aisp/ina/_ai_network.py,sha256=4OXqr08RBLt0ZcNwBZHsAyolbnw4eM6wAoVwtaklcgs,21416
|
14
14
|
aisp/ina/_base.py,sha256=ckKStxiuuwz8O3O2KEb4JFLIifH3I-4O3rhfrmH9oMU,4402
|
15
15
|
aisp/nsa/__init__.py,sha256=vL_HbASV6aGiiHAMx0UShqkL-ly-OYcqQLasKdu9p-M,425
|
16
16
|
aisp/nsa/_base.py,sha256=3YKlZzA3yhP2uQHfhyKswbHUutlxkOR4wn6N10nSO-w,4119
|
17
|
-
aisp/nsa/_binary_negative_selection.py,sha256=
|
18
|
-
aisp/nsa/_negative_selection.py,sha256=
|
17
|
+
aisp/nsa/_binary_negative_selection.py,sha256=Fj8TnS1E9zJOlEKUW4AREYaqftSCO7DSc7lU4L0s_cc,9767
|
18
|
+
aisp/nsa/_negative_selection.py,sha256=u3-dKRA-o5J6PUwsazD0lSG3NuUFrsDXZ08jPeU0LsA,18791
|
19
19
|
aisp/nsa/_ns_core.py,sha256=SXkZL-p2VQygU4Pf6J5AP_yPzU4cR6aU6wx-e_vlm-c,5021
|
20
20
|
aisp/utils/__init__.py,sha256=RzpKhkg8nCZi4G0C4il97f3ESYs7Bbxq6EjTeOQQUGk,195
|
21
21
|
aisp/utils/_multiclass.py,sha256=ZC7D2RG1BgkpzjZMU4IHC6uAKyFcqCx10d2jbxCM9xE,1136
|
22
|
-
aisp/utils/distance.py,sha256=
|
22
|
+
aisp/utils/distance.py,sha256=Ad9wnNL3TwBTk-Tav0jMuuUWWiPxTkFhIYmgepq5Y0Q,6556
|
23
23
|
aisp/utils/metrics.py,sha256=zDAScDbHRnfu24alRcZ6fEIUaWNoCD-QCtOCFBWPPo8,1277
|
24
24
|
aisp/utils/sanitizers.py,sha256=u1GizdJ-RKfPWJLnuFiM09lpItZMhDR_EvK8YdVHwDk,1858
|
25
|
-
aisp/utils/types.py,sha256=
|
25
|
+
aisp/utils/types.py,sha256=cDZHpkzETtVa2rJOB0jBXqjWMNJXhCcWsw8-jvMRRkQ,1306
|
26
26
|
aisp/utils/validation.py,sha256=RqcS2VdFXkNcOH_7Y3yPi7FBoGWR_ReLBPDBx0UMCqI,1431
|
27
|
-
aisp-0.3.
|
28
|
-
aisp-0.3.
|
29
|
-
aisp-0.3.
|
30
|
-
aisp-0.3.
|
31
|
-
aisp-0.3.
|
27
|
+
aisp-0.3.21.dist-info/licenses/LICENSE,sha256=fTqV5eBpeAZO0_jit8j4Ref9ikBSlHJ8xwj5TLg7gFk,7817
|
28
|
+
aisp-0.3.21.dist-info/METADATA,sha256=ex0Zb0CWU403OoOogGunOH8p6JauAr3tyxXjBQ-txJ8,5157
|
29
|
+
aisp-0.3.21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
30
|
+
aisp-0.3.21.dist-info/top_level.txt,sha256=Q5aJi_rAVT5UNS1As0ZafoyS5dwNibnoyOYV7RWUB9s,5
|
31
|
+
aisp-0.3.21.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|