aisp 0.3.21__py3-none-any.whl → 0.4.0__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/__init__.py +17 -4
- aisp/base/__init__.py +21 -2
- aisp/base/_classifier.py +4 -2
- aisp/base/_optimizer.py +188 -0
- aisp/base/mutation.py +86 -18
- aisp/base/populations.py +49 -0
- aisp/csa/__init__.py +12 -1
- aisp/csa/_cell.py +2 -2
- aisp/csa/_clonalg.py +369 -0
- aisp/ina/__init__.py +2 -2
- aisp/ina/_ai_network.py +5 -4
- aisp/ina/_base.py +0 -40
- aisp/nsa/__init__.py +7 -0
- aisp/utils/display.py +185 -0
- aisp/utils/sanitizers.py +53 -1
- aisp/utils/types.py +10 -2
- {aisp-0.3.21.dist-info → aisp-0.4.0.dist-info}/METADATA +2 -1
- aisp-0.4.0.dist-info/RECORD +35 -0
- aisp-0.3.21.dist-info/RECORD +0 -31
- {aisp-0.3.21.dist-info → aisp-0.4.0.dist-info}/WHEEL +0 -0
- {aisp-0.3.21.dist-info → aisp-0.4.0.dist-info}/licenses/LICENSE +0 -0
- {aisp-0.3.21.dist-info → aisp-0.4.0.dist-info}/top_level.txt +0 -0
aisp/utils/sanitizers.py
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
"""Utility functions for validation and treatment of parameters."""
|
2
2
|
|
3
|
-
from typing import TypeVar, Iterable, Callable, Any, Optional
|
3
|
+
from typing import TypeVar, Iterable, Callable, Any, Optional, Dict
|
4
|
+
|
5
|
+
import numpy as np
|
6
|
+
import numpy.typing as npt
|
4
7
|
|
5
8
|
T = TypeVar('T')
|
6
9
|
|
@@ -62,3 +65,52 @@ def sanitize_seed(seed: Any) -> Optional[int]:
|
|
62
65
|
The original seed if it is a non-negative integer, or None if it is invalid.
|
63
66
|
"""
|
64
67
|
return seed if isinstance(seed, int) and seed >= 0 else None
|
68
|
+
|
69
|
+
|
70
|
+
def sanitize_bounds(bounds: Any, problem_size: int) -> Dict[str, npt.NDArray[np.float64]]:
|
71
|
+
"""Validate and normalize feature bounds.
|
72
|
+
|
73
|
+
Parameters
|
74
|
+
----------
|
75
|
+
bounds : Any
|
76
|
+
The input bounds, which must be either None or a dictionary with 'low'
|
77
|
+
and 'high' keys.
|
78
|
+
problem_size : int
|
79
|
+
The expected length for the normalized bounds lists, corresponding to
|
80
|
+
the number of features in the problem.
|
81
|
+
|
82
|
+
Returns
|
83
|
+
-------
|
84
|
+
Dict[str, list]
|
85
|
+
Dictionary {'low': [low_1, ..., low_N], 'high': [high_1, ..., high_N]}.
|
86
|
+
|
87
|
+
Raises
|
88
|
+
------
|
89
|
+
TypeError
|
90
|
+
If `bounds` is not None and not a dict with 'low'/'high', or if items are non-numeric.
|
91
|
+
ValueError
|
92
|
+
If provided iterables have the wrong length.
|
93
|
+
"""
|
94
|
+
if bounds is None or not isinstance(bounds, dict) or set(bounds.keys()) != {'low', 'high'}:
|
95
|
+
raise ValueError("bounds expects a dict with keys 'low' and 'high'")
|
96
|
+
result = {}
|
97
|
+
|
98
|
+
for key in ['low', 'high']:
|
99
|
+
value = bounds[key]
|
100
|
+
if isinstance(value, (float, int)):
|
101
|
+
result[key] = np.array([value] * problem_size).astype(dtype=np.float64)
|
102
|
+
else:
|
103
|
+
if not isinstance(value, (list, np.ndarray)):
|
104
|
+
raise TypeError(
|
105
|
+
f"{key} must be a list or numpy array, got {type(value).__name__}"
|
106
|
+
)
|
107
|
+
if not all(isinstance(i, (float, int)) for i in value):
|
108
|
+
raise TypeError(f"All elements of {key} must be numeric")
|
109
|
+
|
110
|
+
value = np.array(value).astype(dtype=np.float64)
|
111
|
+
if len(value) != problem_size:
|
112
|
+
raise ValueError(
|
113
|
+
f"The size of {key} must be equal to the size of the problem ({problem_size})"
|
114
|
+
)
|
115
|
+
result[key] = value
|
116
|
+
return result
|
aisp/utils/types.py
CHANGED
@@ -8,6 +8,12 @@ FeatureType : Literal["binary-features", "continuous-features", "ranged-features
|
|
8
8
|
- "binary-features": Features with binary values (e.g., 0 or 1).
|
9
9
|
- "continuous-features": Features with continuous numeric values.
|
10
10
|
- "ranged-features": Features represented by ranges or intervals.
|
11
|
+
FeatureTypeAll : Literal["binary-features", "continuous-features", "ranged-features"]
|
12
|
+
Specifies the type of features in the input data. Can be one of:
|
13
|
+
- "binary-features": Features with binary values (e.g., 0 or 1).
|
14
|
+
- "continuous-features": Features with continuous numeric values.
|
15
|
+
- "ranged-features": Features represented by ranges or intervals.
|
16
|
+
- "permutation-features": Features represented by permutation.
|
11
17
|
|
12
18
|
MetricType : Literal["manhattan", "minkowski", "euclidean"]
|
13
19
|
Specifies the distance metric to use for calculations. Possible values:
|
@@ -20,12 +26,14 @@ MetricType : Literal["manhattan", "minkowski", "euclidean"]
|
|
20
26
|
"""
|
21
27
|
|
22
28
|
|
23
|
-
from typing import Literal, TypeAlias
|
24
|
-
|
29
|
+
from typing import Literal, TypeAlias, Union
|
25
30
|
|
26
31
|
FeatureType: TypeAlias = Literal[
|
27
32
|
"binary-features",
|
28
33
|
"continuous-features",
|
29
34
|
"ranged-features"
|
30
35
|
]
|
36
|
+
|
37
|
+
FeatureTypeAll: TypeAlias = Union[FeatureType, Literal["permutation-features"]]
|
38
|
+
|
31
39
|
MetricType: TypeAlias = Literal["manhattan", "minkowski", "euclidean"]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: aisp
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.4.0
|
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>
|
@@ -86,6 +86,7 @@ Artificial Immune Systems (AIS) are inspired by the vertebrate immune system, cr
|
|
86
86
|
> - [x] [**Negative Selection.**](https://ais-package.github.io/docs/aisp-techniques/negative-selection/)
|
87
87
|
> - [x] [**Clonal Selection Algorithms.**](https://ais-package.github.io/docs/aisp-techniques/clonal-selection-algorithms/)
|
88
88
|
> * [AIRS - Artificial Immune Recognition System](https://ais-package.github.io/docs/aisp-techniques/clonal-selection-algorithms/airs/)
|
89
|
+
> * [CLONALG - Clonal Selection Algorithm](https://ais-package.github.io/docs/aisp-techniques/clonal-selection-algorithms/clonalg)
|
89
90
|
> - [ ] *Danger Theory.*
|
90
91
|
> - [x] [*Immune Network Theory.*](https://ais-package.github.io/docs/aisp-techniques/immune-network-theory/)
|
91
92
|
> - [AiNet - Artificial Immune Network para Clustering and Compression](https://ais-package.github.io/docs/aisp-techniques/immune-network-theory/ainet)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
aisp/__init__.py,sha256=9HfYCxZnkj-4R6uZX6ZM6mJt93qzkDo3_h_UwjY6FW0,1244
|
2
|
+
aisp/exceptions.py,sha256=I9JaQx6p8Jo7qjwwcrqnuewQgyBdUnOSSZofPoBeDNE,1954
|
3
|
+
aisp/base/__init__.py,sha256=NioBFTZmfG6SVk29kH2aQGqpWjvsNlEqY_sMmYLDdFg,763
|
4
|
+
aisp/base/_base.py,sha256=uTVh__hQJGe8RCOzCet4ZV3vQbwgj5fXAt4Jdf0x1r0,1792
|
5
|
+
aisp/base/_classifier.py,sha256=XibBY-1xPPc-AX6rJaxTOqSQ-7thzAgeR9VggBX8hYk,3536
|
6
|
+
aisp/base/_clusterer.py,sha256=-wzZ4vSI_ZtPvLYryfJ75VaKcp67jxl92lJxfjopVYc,2468
|
7
|
+
aisp/base/_optimizer.py,sha256=81nRa_KJqw-UZ4IYUFvWWq6bpOR5TMCKr41MNet6oj8,6517
|
8
|
+
aisp/base/mutation.py,sha256=S-oh8O0ndMOE8bYIhhKhzxCS99r3nefFVEZ3cb7X3ps,7522
|
9
|
+
aisp/base/populations.py,sha256=5y125iJgTu_S0XI1BlAECZLSFua75l3Oo47x_3uI7ss,1750
|
10
|
+
aisp/csa/__init__.py,sha256=8e6zUPxZAlQ4NDpDhM4symeewzAwk8-CkqYfeBiPvGQ,799
|
11
|
+
aisp/csa/_ai_recognition_sys.py,sha256=00swgeB2CgpQ4zz2bvuVk50jN7839g9pbb33_9cdsv0,18947
|
12
|
+
aisp/csa/_base.py,sha256=CIj6NDNAH-GCuZpDXAHEWe7jSHUum7mUOnnvXnkEy60,3593
|
13
|
+
aisp/csa/_cell.py,sha256=KS0zqJ4JVipUI6oikDUkzeL2Ayml_GtCQ_HjDQB-HQc,1879
|
14
|
+
aisp/csa/_clonalg.py,sha256=Y-WOy27HmstMamyTBg4K1kqXlrxy7iahS4TmfAcc-kM,13770
|
15
|
+
aisp/ina/__init__.py,sha256=D69sBmTCa0LYd_dzTbb0QvhgMpWWztD2VIjLCZig2c4,392
|
16
|
+
aisp/ina/_ai_network.py,sha256=fmi7wt8EJPuZKmv-iB6J2HDDv0c4lKED-xknmxy-45o,21497
|
17
|
+
aisp/ina/_base.py,sha256=O-jiCgqQG_QnG1xlp7mv5u9BZTmuW4pnAV09L9HvjBE,2797
|
18
|
+
aisp/nsa/__init__.py,sha256=33RJ5yDW2W-J5ZdUBB1Fk_XFw4bv8AXWvO_amkm79xA,713
|
19
|
+
aisp/nsa/_base.py,sha256=3YKlZzA3yhP2uQHfhyKswbHUutlxkOR4wn6N10nSO-w,4119
|
20
|
+
aisp/nsa/_binary_negative_selection.py,sha256=Fj8TnS1E9zJOlEKUW4AREYaqftSCO7DSc7lU4L0s_cc,9767
|
21
|
+
aisp/nsa/_negative_selection.py,sha256=u3-dKRA-o5J6PUwsazD0lSG3NuUFrsDXZ08jPeU0LsA,18791
|
22
|
+
aisp/nsa/_ns_core.py,sha256=SXkZL-p2VQygU4Pf6J5AP_yPzU4cR6aU6wx-e_vlm-c,5021
|
23
|
+
aisp/utils/__init__.py,sha256=RzpKhkg8nCZi4G0C4il97f3ESYs7Bbxq6EjTeOQQUGk,195
|
24
|
+
aisp/utils/_multiclass.py,sha256=ZC7D2RG1BgkpzjZMU4IHC6uAKyFcqCx10d2jbxCM9xE,1136
|
25
|
+
aisp/utils/display.py,sha256=bKRGaB_VVHtKLbJE_XDJXD2fVR1qYX0wxKOlLAqVdYw,5752
|
26
|
+
aisp/utils/distance.py,sha256=Ad9wnNL3TwBTk-Tav0jMuuUWWiPxTkFhIYmgepq5Y0Q,6556
|
27
|
+
aisp/utils/metrics.py,sha256=zDAScDbHRnfu24alRcZ6fEIUaWNoCD-QCtOCFBWPPo8,1277
|
28
|
+
aisp/utils/sanitizers.py,sha256=-ZMn8L5nnRNhtJ3GNr4KkS9383du6B6QkV48xQl3fzw,3771
|
29
|
+
aisp/utils/types.py,sha256=LV2J1m-VG-55CHoLGOqONr3OKsrwqTI2e5APSNr2si4,1833
|
30
|
+
aisp/utils/validation.py,sha256=RqcS2VdFXkNcOH_7Y3yPi7FBoGWR_ReLBPDBx0UMCqI,1431
|
31
|
+
aisp-0.4.0.dist-info/licenses/LICENSE,sha256=fTqV5eBpeAZO0_jit8j4Ref9ikBSlHJ8xwj5TLg7gFk,7817
|
32
|
+
aisp-0.4.0.dist-info/METADATA,sha256=RJHKap1PrJm0DGmSQYjDWRz70HF8vgPnUirnJT7DK5s,5292
|
33
|
+
aisp-0.4.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
34
|
+
aisp-0.4.0.dist-info/top_level.txt,sha256=Q5aJi_rAVT5UNS1As0ZafoyS5dwNibnoyOYV7RWUB9s,5
|
35
|
+
aisp-0.4.0.dist-info/RECORD,,
|
aisp-0.3.21.dist-info/RECORD
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
aisp/__init__.py,sha256=LuDzEKwj0mzm-0Xqv79qvYMJc7eroVZaHfWRQQRlgFY,708
|
2
|
-
aisp/exceptions.py,sha256=I9JaQx6p8Jo7qjwwcrqnuewQgyBdUnOSSZofPoBeDNE,1954
|
3
|
-
aisp/base/__init__.py,sha256=b-YzeW1iIAEp7JReS6TVzTeBZwFVsfxtOqG9W4gDvdc,211
|
4
|
-
aisp/base/_base.py,sha256=uTVh__hQJGe8RCOzCet4ZV3vQbwgj5fXAt4Jdf0x1r0,1792
|
5
|
-
aisp/base/_classifier.py,sha256=xmD7SlPFjdWdrK7dkK8GzLFGOq5w_4jkzK4J-eqHlwA,3375
|
6
|
-
aisp/base/_clusterer.py,sha256=-wzZ4vSI_ZtPvLYryfJ75VaKcp67jxl92lJxfjopVYc,2468
|
7
|
-
aisp/base/mutation.py,sha256=MJ5BZmJlV2BiECUbo-d4HKJ6MeTI5KuZQqRzevVcF-4,4762
|
8
|
-
aisp/csa/__init__.py,sha256=708jwpqia10bqmh-4-_srwwNuBh7jf2Zix-u8Hfbzmk,348
|
9
|
-
aisp/csa/_ai_recognition_sys.py,sha256=00swgeB2CgpQ4zz2bvuVk50jN7839g9pbb33_9cdsv0,18947
|
10
|
-
aisp/csa/_base.py,sha256=CIj6NDNAH-GCuZpDXAHEWe7jSHUum7mUOnnvXnkEy60,3593
|
11
|
-
aisp/csa/_cell.py,sha256=GUxnzvPyIbBm1YYkMhSx0tcV_oyDhJ7wAo5gtr_1CoY,1845
|
12
|
-
aisp/ina/__init__.py,sha256=cOnxGcxrBdg6lLv2w2sdlToMahKMh_Gw57AfUUPQjMo,329
|
13
|
-
aisp/ina/_ai_network.py,sha256=4OXqr08RBLt0ZcNwBZHsAyolbnw4eM6wAoVwtaklcgs,21416
|
14
|
-
aisp/ina/_base.py,sha256=ckKStxiuuwz8O3O2KEb4JFLIifH3I-4O3rhfrmH9oMU,4402
|
15
|
-
aisp/nsa/__init__.py,sha256=vL_HbASV6aGiiHAMx0UShqkL-ly-OYcqQLasKdu9p-M,425
|
16
|
-
aisp/nsa/_base.py,sha256=3YKlZzA3yhP2uQHfhyKswbHUutlxkOR4wn6N10nSO-w,4119
|
17
|
-
aisp/nsa/_binary_negative_selection.py,sha256=Fj8TnS1E9zJOlEKUW4AREYaqftSCO7DSc7lU4L0s_cc,9767
|
18
|
-
aisp/nsa/_negative_selection.py,sha256=u3-dKRA-o5J6PUwsazD0lSG3NuUFrsDXZ08jPeU0LsA,18791
|
19
|
-
aisp/nsa/_ns_core.py,sha256=SXkZL-p2VQygU4Pf6J5AP_yPzU4cR6aU6wx-e_vlm-c,5021
|
20
|
-
aisp/utils/__init__.py,sha256=RzpKhkg8nCZi4G0C4il97f3ESYs7Bbxq6EjTeOQQUGk,195
|
21
|
-
aisp/utils/_multiclass.py,sha256=ZC7D2RG1BgkpzjZMU4IHC6uAKyFcqCx10d2jbxCM9xE,1136
|
22
|
-
aisp/utils/distance.py,sha256=Ad9wnNL3TwBTk-Tav0jMuuUWWiPxTkFhIYmgepq5Y0Q,6556
|
23
|
-
aisp/utils/metrics.py,sha256=zDAScDbHRnfu24alRcZ6fEIUaWNoCD-QCtOCFBWPPo8,1277
|
24
|
-
aisp/utils/sanitizers.py,sha256=u1GizdJ-RKfPWJLnuFiM09lpItZMhDR_EvK8YdVHwDk,1858
|
25
|
-
aisp/utils/types.py,sha256=cDZHpkzETtVa2rJOB0jBXqjWMNJXhCcWsw8-jvMRRkQ,1306
|
26
|
-
aisp/utils/validation.py,sha256=RqcS2VdFXkNcOH_7Y3yPi7FBoGWR_ReLBPDBx0UMCqI,1431
|
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
|