aisp 0.3.1__tar.gz → 0.3.21__tar.gz
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-0.3.1 → aisp-0.3.21}/PKG-INFO +6 -6
- {aisp-0.3.1 → aisp-0.3.21}/README.md +5 -5
- {aisp-0.3.1 → aisp-0.3.21}/aisp/__init__.py +2 -2
- {aisp-0.3.1 → aisp-0.3.21}/aisp/base/__init__.py +1 -1
- {aisp-0.3.1 → aisp-0.3.21}/aisp/base/_classifier.py +1 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp/base/_clusterer.py +1 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp/base/mutation.py +2 -2
- {aisp-0.3.1 → aisp-0.3.21}/aisp/csa/_ai_recognition_sys.py +14 -11
- {aisp-0.3.1 → aisp-0.3.21}/aisp/csa/_base.py +1 -1
- {aisp-0.3.1 → aisp-0.3.21}/aisp/ina/_ai_network.py +15 -6
- {aisp-0.3.1 → aisp-0.3.21}/aisp/ina/_base.py +1 -2
- {aisp-0.3.1 → aisp-0.3.21}/aisp/nsa/_binary_negative_selection.py +4 -3
- {aisp-0.3.1 → aisp-0.3.21}/aisp/nsa/_negative_selection.py +8 -7
- {aisp-0.3.1 → aisp-0.3.21}/aisp/utils/_multiclass.py +1 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp/utils/distance.py +4 -4
- {aisp-0.3.1 → aisp-0.3.21}/aisp/utils/types.py +3 -3
- {aisp-0.3.1 → aisp-0.3.21}/aisp.egg-info/PKG-INFO +6 -6
- {aisp-0.3.1 → aisp-0.3.21}/pyproject.toml +1 -1
- {aisp-0.3.1 → aisp-0.3.21}/LICENSE +0 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp/base/_base.py +0 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp/csa/__init__.py +0 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp/csa/_cell.py +0 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp/exceptions.py +0 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp/ina/__init__.py +0 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp/nsa/__init__.py +0 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp/nsa/_base.py +0 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp/nsa/_ns_core.py +0 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp/utils/__init__.py +0 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp/utils/metrics.py +0 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp/utils/sanitizers.py +0 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp/utils/validation.py +0 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp.egg-info/SOURCES.txt +0 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp.egg-info/dependency_links.txt +0 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp.egg-info/requires.txt +0 -0
- {aisp-0.3.1 → aisp-0.3.21}/aisp.egg-info/top_level.txt +0 -0
- {aisp-0.3.1 → aisp-0.3.21}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: aisp
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.21
|
4
4
|
Summary: Package with techniques of artificial immune systems.
|
5
5
|
Author-email: João Paulo da Silva Barros <jpsilvabarr@gmail.com>
|
6
6
|
Maintainer-email: Alison Zille Lopes <alisonzille@gmail.com>
|
@@ -83,12 +83,12 @@ Artificial Immune Systems (AIS) are inspired by the vertebrate immune system, cr
|
|
83
83
|
|
84
84
|
##### Algorithms implemented:
|
85
85
|
|
86
|
-
> - [x] [**Negative Selection.**](https://ais-package.github.io/docs/aisp-techniques/
|
87
|
-
> - [x] [**Clonal Selection Algorithms.**](https://ais-package.github.io/docs/aisp-techniques/
|
88
|
-
> * [AIRS - Artificial Immune Recognition System](https://ais-package.github.io/docs/aisp-techniques/
|
86
|
+
> - [x] [**Negative Selection.**](https://ais-package.github.io/docs/aisp-techniques/negative-selection/)
|
87
|
+
> - [x] [**Clonal Selection Algorithms.**](https://ais-package.github.io/docs/aisp-techniques/clonal-selection-algorithms/)
|
88
|
+
> * [AIRS - Artificial Immune Recognition System](https://ais-package.github.io/docs/aisp-techniques/clonal-selection-algorithms/airs/)
|
89
89
|
> - [ ] *Danger Theory.*
|
90
|
-
> - [x] [*Immune Network Theory.*](https://ais-package.github.io/docs/aisp-techniques/
|
91
|
-
> - [AiNet - Artificial Immune Network para Clustering and Compression](https://ais-package.github.io/docs/aisp-techniques/
|
90
|
+
> - [x] [*Immune Network Theory.*](https://ais-package.github.io/docs/aisp-techniques/immune-network-theory/)
|
91
|
+
> - [AiNet - Artificial Immune Network para Clustering and Compression](https://ais-package.github.io/docs/aisp-techniques/immune-network-theory/ainet)
|
92
92
|
|
93
93
|
</section>
|
94
94
|
|
@@ -48,12 +48,12 @@ Artificial Immune Systems (AIS) are inspired by the vertebrate immune system, cr
|
|
48
48
|
|
49
49
|
##### Algorithms implemented:
|
50
50
|
|
51
|
-
> - [x] [**Negative Selection.**](https://ais-package.github.io/docs/aisp-techniques/
|
52
|
-
> - [x] [**Clonal Selection Algorithms.**](https://ais-package.github.io/docs/aisp-techniques/
|
53
|
-
> * [AIRS - Artificial Immune Recognition System](https://ais-package.github.io/docs/aisp-techniques/
|
51
|
+
> - [x] [**Negative Selection.**](https://ais-package.github.io/docs/aisp-techniques/negative-selection/)
|
52
|
+
> - [x] [**Clonal Selection Algorithms.**](https://ais-package.github.io/docs/aisp-techniques/clonal-selection-algorithms/)
|
53
|
+
> * [AIRS - Artificial Immune Recognition System](https://ais-package.github.io/docs/aisp-techniques/clonal-selection-algorithms/airs/)
|
54
54
|
> - [ ] *Danger Theory.*
|
55
|
-
> - [x] [*Immune Network Theory.*](https://ais-package.github.io/docs/aisp-techniques/
|
56
|
-
> - [AiNet - Artificial Immune Network para Clustering and Compression](https://ais-package.github.io/docs/aisp-techniques/
|
55
|
+
> - [x] [*Immune Network Theory.*](https://ais-package.github.io/docs/aisp-techniques/immune-network-theory/)
|
56
|
+
> - [AiNet - Artificial Immune Network para Clustering and Compression](https://ais-package.github.io/docs/aisp-techniques/immune-network-theory/ainet)
|
57
57
|
|
58
58
|
</section>
|
59
59
|
|
@@ -14,11 +14,11 @@ https://ais-package.github.io/docs/intro
|
|
14
14
|
"""
|
15
15
|
|
16
16
|
from . import csa
|
17
|
-
from . import nsa
|
18
17
|
from . import ina
|
18
|
+
from . import nsa
|
19
19
|
|
20
20
|
__author__ = "AISP Development Team"
|
21
|
-
__version__ = "0.3.
|
21
|
+
__version__ = "0.3.2"
|
22
22
|
__all__ = [
|
23
23
|
'csa',
|
24
24
|
'nsa',
|
@@ -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
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"""Artificial Immune Recognition System (AIRS)."""
|
2
2
|
|
3
3
|
from __future__ import annotations
|
4
|
+
|
4
5
|
import random
|
5
6
|
from collections import Counter
|
6
7
|
from heapq import nlargest
|
@@ -12,13 +13,13 @@ import numpy.typing as npt
|
|
12
13
|
from scipy.spatial.distance import pdist
|
13
14
|
from tqdm import tqdm
|
14
15
|
|
15
|
-
from
|
16
|
+
from ._base import BaseAIRS
|
16
17
|
from ._cell import Cell
|
17
|
-
from ..
|
18
|
+
from ..base import set_seed_numba
|
18
19
|
from ..utils.distance import hamming, compute_metric_distance, get_metric_code
|
20
|
+
from ..utils.sanitizers import sanitize_param, sanitize_seed, sanitize_choice
|
19
21
|
from ..utils.types import FeatureType, MetricType
|
20
22
|
from ..utils.validation import detect_vector_data_type
|
21
|
-
from ._base import BaseAIRS
|
22
23
|
|
23
24
|
|
24
25
|
class _ARB(Cell):
|
@@ -110,13 +111,13 @@ class AIRS(BaseAIRS):
|
|
110
111
|
Way to calculate the distance between the detector and the sample:
|
111
112
|
|
112
113
|
* ``'Euclidean'`` ➜ The calculation of the distance is given by the expression:
|
113
|
-
√( (x₁
|
114
|
+
√( (x₁ - x₂)² + (y₁ - y₂)² + ... + (yn - yn)²).
|
114
115
|
|
115
116
|
* ``'minkowski'`` ➜ The calculation of the distance is given by the expression:
|
116
|
-
( |X₁
|
117
|
+
( |X₁ - Y₁|p + |X₂ - Y₂|p + ... + |Xn - Yn|p) ¹/ₚ.
|
117
118
|
|
118
119
|
* ``'manhattan'`` ➜ The calculation of the distance is given by the expression:
|
119
|
-
( |x₁
|
120
|
+
( |x₁ - x₂| + |y₁ - y₂| + ... + |yn - yn|).
|
120
121
|
|
121
122
|
seed : int
|
122
123
|
Seed for the random generation of detector values. Defaults to None.
|
@@ -138,7 +139,7 @@ class AIRS(BaseAIRS):
|
|
138
139
|
|
139
140
|
References
|
140
141
|
----------
|
141
|
-
.. [1] Brabazon, A., O
|
142
|
+
.. [1] Brabazon, A., O'Neill, M., & McGarraghy, S. (2015). Natural Computing Algorithms. In
|
142
143
|
Natural Computing Series. Springer Berlin Heidelberg.
|
143
144
|
https://doi.org/10.1007/978-3-662-43631-8
|
144
145
|
|
@@ -194,6 +195,7 @@ class AIRS(BaseAIRS):
|
|
194
195
|
self.affinity_threshold = 0.0
|
195
196
|
self.classes = []
|
196
197
|
self._bounds: Optional[npt.NDArray[np.float64]] = None
|
198
|
+
self._n_features: Optional[int] = None
|
197
199
|
|
198
200
|
@property
|
199
201
|
def cells_memory(self) -> Optional[Dict[str, list[Cell]]]:
|
@@ -234,6 +236,7 @@ class AIRS(BaseAIRS):
|
|
234
236
|
self._bounds = np.vstack([np.min(X, axis=0), np.max(X, axis=0)])
|
235
237
|
|
236
238
|
self.classes = np.unique(y)
|
239
|
+
self._n_features = X.shape[1]
|
237
240
|
sample_index = self._slice_index_list_by_class(y)
|
238
241
|
progress = tqdm(
|
239
242
|
total=len(y),
|
@@ -329,11 +332,11 @@ class AIRS(BaseAIRS):
|
|
329
332
|
An ndarray of the form ``C`` [``N samples``], containing the predicted classes for
|
330
333
|
``X``. or ``None``: If there are no detectors for the prediction.
|
331
334
|
"""
|
332
|
-
if self._all_class_cell_vectors is None:
|
335
|
+
if self._all_class_cell_vectors is None or self._n_features is None:
|
333
336
|
return None
|
334
337
|
|
335
338
|
super()._check_and_raise_exceptions_predict(
|
336
|
-
X,
|
339
|
+
X, self._n_features, self._feature_type
|
337
340
|
)
|
338
341
|
|
339
342
|
c: list = []
|
@@ -379,7 +382,7 @@ class AIRS(BaseAIRS):
|
|
379
382
|
|
380
383
|
References
|
381
384
|
----------
|
382
|
-
.. [1] Brabazon, A., O
|
385
|
+
.. [1] Brabazon, A., O'Neill, M., & McGarraghy, S. (2015).
|
383
386
|
Natural Computing Algorithms. Natural Computing Series.
|
384
387
|
Springer Berlin Heidelberg. https://doi.org/10.1007/978-3-662-43631-8
|
385
388
|
"""
|
@@ -440,7 +443,7 @@ class AIRS(BaseAIRS):
|
|
440
443
|
distances = pdist(antigens_list, metric="hamming")
|
441
444
|
else:
|
442
445
|
metric_kwargs = {'p': self.p} if self.metric == 'minkowski' else {}
|
443
|
-
distances = pdist(antigens_list, metric=self.metric, **metric_kwargs)
|
446
|
+
distances = pdist(antigens_list, metric=self.metric, **metric_kwargs) # type: ignore
|
444
447
|
|
445
448
|
n = antigens_list.shape[0]
|
446
449
|
sum_affinity = np.sum(1.0 - (distances / (1.0 + distances)))
|
@@ -5,9 +5,9 @@ from abc import ABC
|
|
5
5
|
import numpy as np
|
6
6
|
import numpy.typing as npt
|
7
7
|
|
8
|
+
from ..base import BaseClassifier
|
8
9
|
from ..exceptions import FeatureDimensionMismatch
|
9
10
|
from ..utils.types import FeatureType
|
10
|
-
from ..base import BaseClassifier
|
11
11
|
|
12
12
|
|
13
13
|
class BaseAIRS(BaseClassifier, ABC):
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"""Artificial Immune Network (AiNet)."""
|
2
2
|
|
3
3
|
from __future__ import annotations
|
4
|
+
|
4
5
|
from collections import Counter
|
5
6
|
from heapq import nlargest
|
6
7
|
from typing import Optional
|
@@ -15,8 +16,8 @@ from ._base import BaseAiNet
|
|
15
16
|
from ..base import set_seed_numba
|
16
17
|
from ..base.mutation import clone_and_mutate_binary, clone_and_mutate_continuous, \
|
17
18
|
clone_and_mutate_ranged
|
18
|
-
from ..utils.sanitizers import sanitize_choice, sanitize_param, sanitize_seed
|
19
19
|
from ..utils.distance import hamming, compute_metric_distance, get_metric_code
|
20
|
+
from ..utils.sanitizers import sanitize_choice, sanitize_param, sanitize_seed
|
20
21
|
from ..utils.types import FeatureType, MetricType
|
21
22
|
from ..utils.validation import detect_vector_data_type
|
22
23
|
|
@@ -28,7 +29,7 @@ class AiNet(BaseAiNet):
|
|
28
29
|
clustering and data compression tasks. The aiNet algorithm uses principles from immune
|
29
30
|
network theory, clonal selection, and affinity maturation to compress high-dimensional
|
30
31
|
datasets. [1]_
|
31
|
-
For clustering, the class uses SciPy
|
32
|
+
For clustering, the class uses SciPy's implementation of the **Minimum Spanning Tree**
|
32
33
|
(MST) to remove the most distant nodes and separate the groups. [2]_
|
33
34
|
|
34
35
|
Parameters
|
@@ -57,13 +58,13 @@ class AiNet(BaseAiNet):
|
|
57
58
|
Way to calculate the distance between the detector and the sample:
|
58
59
|
|
59
60
|
* ``'Euclidean'`` ➜ The calculation of the distance is given by the expression:
|
60
|
-
√( (x₁
|
61
|
+
√( (x₁ - x₂)² + (y₁ - y₂)² + ... + (yn - yn)²).
|
61
62
|
|
62
63
|
* ``'minkowski'`` ➜ The calculation of the distance is given by the expression:
|
63
|
-
( |X₁
|
64
|
+
( |X₁ - Y₁|p + |X₂ - Y₂|p + ... + |Xn - Yn|p) ¹/ₚ.
|
64
65
|
|
65
66
|
* ``'manhattan'`` ➜ The calculation of the distance is given by the expression:
|
66
|
-
( |x₁
|
67
|
+
( |x₁ - x₂| + |y₁ - y₂| + ... + |yn - yn|).
|
67
68
|
|
68
69
|
seed : Optional[int]
|
69
70
|
Seed for the random generation of detector values. Defaults to None.
|
@@ -454,7 +455,7 @@ class AiNet(BaseAiNet):
|
|
454
455
|
"""
|
455
456
|
u = np.reshape(u, (1, -1))
|
456
457
|
v = np.atleast_2d(v)
|
457
|
-
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
|
458
459
|
|
459
460
|
return 1 - (distances / (1 + distances))
|
460
461
|
|
@@ -522,6 +523,8 @@ class AiNet(BaseAiNet):
|
|
522
523
|
------
|
523
524
|
ValueError
|
524
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.
|
525
528
|
|
526
529
|
Updates
|
527
530
|
-------
|
@@ -533,6 +536,12 @@ class AiNet(BaseAiNet):
|
|
533
536
|
if self._mst_structure is None:
|
534
537
|
raise ValueError("The Minimum Spanning Tree (MST) has not yet been created.")
|
535
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
|
+
|
536
545
|
if mst_inconsistency_factor is not None:
|
537
546
|
self.mst_inconsistency_factor = mst_inconsistency_factor
|
538
547
|
|
@@ -1,19 +1,20 @@
|
|
1
1
|
"""Negative Selection Algorithm."""
|
2
2
|
|
3
3
|
from __future__ import annotations
|
4
|
+
|
4
5
|
from typing import Dict, Literal, Optional, Union
|
5
|
-
from tqdm import tqdm
|
6
6
|
|
7
7
|
import numpy as np
|
8
8
|
import numpy.typing as npt
|
9
|
+
from tqdm import tqdm
|
9
10
|
|
11
|
+
from ._base import BaseNSA
|
10
12
|
from ._ns_core import (
|
11
13
|
check_detector_bnsa_validity,
|
12
14
|
bnsa_class_prediction
|
13
15
|
)
|
14
16
|
from ..exceptions import MaxDiscardsReachedError
|
15
17
|
from ..utils.sanitizers import sanitize_seed, sanitize_param
|
16
|
-
from ._base import BaseNSA
|
17
18
|
|
18
19
|
|
19
20
|
class BNSA(BaseNSA):
|
@@ -236,4 +237,4 @@ class BNSA(BaseNSA):
|
|
236
237
|
else:
|
237
238
|
class_differences[_class_] = distances.sum() / self.N
|
238
239
|
|
239
|
-
c.append(max(class_differences, key=class_differences.get))
|
240
|
+
c.append(max(class_differences, key=class_differences.get)) # type: ignore
|
@@ -1,14 +1,16 @@
|
|
1
1
|
"""Negative Selection Algorithm."""
|
2
2
|
|
3
3
|
from __future__ import annotations
|
4
|
+
|
4
5
|
from typing import Any, Dict, Literal, Optional, Union
|
5
|
-
from tqdm import tqdm
|
6
6
|
|
7
7
|
import numpy as np
|
8
8
|
import numpy.typing as npt
|
9
|
+
from tqdm import tqdm
|
9
10
|
|
10
|
-
from
|
11
|
+
from ._base import BaseNSA, Detector
|
11
12
|
from ._ns_core import check_detector_rnsa_validity
|
13
|
+
from ..base import set_seed_numba
|
12
14
|
from ..exceptions import MaxDiscardsReachedError
|
13
15
|
from ..utils.distance import (
|
14
16
|
min_distance_to_class_vectors,
|
@@ -16,7 +18,6 @@ from ..utils.distance import (
|
|
16
18
|
compute_metric_distance,
|
17
19
|
)
|
18
20
|
from ..utils.sanitizers import sanitize_seed, sanitize_choice, sanitize_param
|
19
|
-
from ._base import BaseNSA, Detector
|
20
21
|
|
21
22
|
|
22
23
|
class RNSA(BaseNSA):
|
@@ -39,11 +40,11 @@ class RNSA(BaseNSA):
|
|
39
40
|
Way to calculate the distance between the detector and the sample:
|
40
41
|
|
41
42
|
+ ``'Euclidean'`` ➜ The calculation of the distance is given by the expression:
|
42
|
-
√( (x₁
|
43
|
+
√( (x₁ - x₂)² + (y₁ - y₂)² + ... + (yn - yn)²).
|
43
44
|
+ ``'minkowski'`` ➜ The calculation of the distance is given by the expression:
|
44
|
-
( |X₁
|
45
|
+
( |X₁ - Y₁|p + |X₂ - Y₂|p + ... + |Xn - Yn|p) ¹/ₚ.
|
45
46
|
+ ``'manhattan'`` ➜ The calculation of the distance is given by the expression:
|
46
|
-
( |x₁
|
47
|
+
( |x₁ - x₂| + |y₁ - y₂| + ... + |yn - yn|) .
|
47
48
|
max_discards : int, default=1000
|
48
49
|
This parameter indicates the maximum number of consecutive detector discards, aimed at
|
49
50
|
preventing a possible infinite loop in case a radius is defined that cannot generate
|
@@ -259,7 +260,7 @@ class RNSA(BaseNSA):
|
|
259
260
|
average_distance[_class_] = np.average(
|
260
261
|
[self.__distance(detector, line) for detector in detectores]
|
261
262
|
)
|
262
|
-
c.append(max(average_distance, key=average_distance.get))
|
263
|
+
c.append(max(average_distance, key=average_distance.get)) # type: ignore
|
263
264
|
return np.array(c)
|
264
265
|
|
265
266
|
def __checks_valid_detector(
|
@@ -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
|
|
@@ -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
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: aisp
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.21
|
4
4
|
Summary: Package with techniques of artificial immune systems.
|
5
5
|
Author-email: João Paulo da Silva Barros <jpsilvabarr@gmail.com>
|
6
6
|
Maintainer-email: Alison Zille Lopes <alisonzille@gmail.com>
|
@@ -83,12 +83,12 @@ Artificial Immune Systems (AIS) are inspired by the vertebrate immune system, cr
|
|
83
83
|
|
84
84
|
##### Algorithms implemented:
|
85
85
|
|
86
|
-
> - [x] [**Negative Selection.**](https://ais-package.github.io/docs/aisp-techniques/
|
87
|
-
> - [x] [**Clonal Selection Algorithms.**](https://ais-package.github.io/docs/aisp-techniques/
|
88
|
-
> * [AIRS - Artificial Immune Recognition System](https://ais-package.github.io/docs/aisp-techniques/
|
86
|
+
> - [x] [**Negative Selection.**](https://ais-package.github.io/docs/aisp-techniques/negative-selection/)
|
87
|
+
> - [x] [**Clonal Selection Algorithms.**](https://ais-package.github.io/docs/aisp-techniques/clonal-selection-algorithms/)
|
88
|
+
> * [AIRS - Artificial Immune Recognition System](https://ais-package.github.io/docs/aisp-techniques/clonal-selection-algorithms/airs/)
|
89
89
|
> - [ ] *Danger Theory.*
|
90
|
-
> - [x] [*Immune Network Theory.*](https://ais-package.github.io/docs/aisp-techniques/
|
91
|
-
> - [AiNet - Artificial Immune Network para Clustering and Compression](https://ais-package.github.io/docs/aisp-techniques/
|
90
|
+
> - [x] [*Immune Network Theory.*](https://ais-package.github.io/docs/aisp-techniques/immune-network-theory/)
|
91
|
+
> - [AiNet - Artificial Immune Network para Clustering and Compression](https://ais-package.github.io/docs/aisp-techniques/immune-network-theory/ainet)
|
92
92
|
|
93
93
|
</section>
|
94
94
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|