aisp 0.1.34__py3-none-any.whl → 0.1.40__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aisp
3
- Version: 0.1.34
3
+ Version: 0.1.40
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>
@@ -9,18 +9,21 @@ Project-URL: Homepage, https://ais-package.github.io/
9
9
  Project-URL: Documentation, https://ais-package.github.io/docs/intro
10
10
  Project-URL: Source Code, https://github.com/AIS-Package/aisp
11
11
  Project-URL: Tracker, https://github.com/AIS-Package/aisp/issues
12
- Keywords: Artificial Immune Systems,classification,Natural computing,machine learning,artificial intelligence
12
+ Keywords: Artificial Immune Systems,classification,Natural computing,machine learning,artificial intelligence,AIS
13
13
  Classifier: Operating System :: OS Independent
14
14
  Classifier: Programming Language :: Python
15
15
  Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.8
17
- Classifier: Programming Language :: Python :: 3.9
18
16
  Classifier: Programming Language :: Python :: 3.10
19
17
  Classifier: Programming Language :: Python :: 3.11
20
- Requires-Python: >=3.8.10
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.10
21
23
  Description-Content-Type: text/markdown
22
24
  License-File: LICENSE
23
25
  Requires-Dist: numpy>=1.22.4
26
+ Requires-Dist: numba>=0.59.0
24
27
  Requires-Dist: scipy>=1.8.1
25
28
  Requires-Dist: tqdm>=4.64.1
26
29
  Dynamic: license-file
@@ -39,7 +42,7 @@ Dynamic: license-file
39
42
  <div class='language-options'>
40
43
 
41
44
  * [English.](#english)
42
- * [Português.](#português)
45
+ * [Português.](https://ais-package.github.io/pt-br/docs/intro)
43
46
 
44
47
  </div>
45
48
 
@@ -52,11 +55,6 @@ Dynamic: license-file
52
55
  ---
53
56
 
54
57
  <section id='english'>
55
- <div align = center>
56
-
57
- ## English
58
-
59
- </div>
60
58
 
61
59
  #### Summary:
62
60
 
@@ -91,7 +89,7 @@ Artificial Immune Systems (AIS) are inspired by the vertebrate immune system, cr
91
89
 
92
90
  #### **Installation**
93
91
 
94
- The module requires installation of [python 3.8.10](https://www.python.org/downloads/) or higher.
92
+ The module requires installation of [python 3.10](https://www.python.org/downloads/) or higher.
95
93
 
96
94
  <section id='dependencies'>
97
95
 
@@ -104,6 +102,7 @@ The module requires installation of [python 3.8.10](https://www.python.org/downl
104
102
  | numpy | ≥ 1.22.4 |
105
103
  | scipy | ≥ 1.8.1 |
106
104
  | tqdm | ≥ 4.64.1 |
105
+ | numba | ≥ 0.59.0 |
107
106
 
108
107
  </div>
109
108
 
@@ -144,104 +143,5 @@ Below are some examples that use a database for classification with the [Jupyter
144
143
 
145
144
  ---
146
145
 
147
-
148
- </section>
149
- </section>
150
-
151
- ---
152
-
153
- <section id='português'>
154
- <div align = center>
155
-
156
- ## Português
157
-
158
- </div>
159
-
160
- #### Sumário:
161
-
162
- > 1. [Introdução.](#introdução)
163
- > 2. [Instalação.](#instalação)
164
- > 1. [Dependências](#dependências)
165
- > 2. [Instalação do usuário](#instalação-do-usuário)
166
- > 3. [Exemplos.](#exemplos)
167
-
168
- ---
169
- <section id='introdução'>
170
-
171
- #### Introdução
172
-
173
- O **AISP** é um pacote python que implementa as técnicas dos sistemas imunológicos artificiais, distribuído sob a licença GNU Lesser General Public License v3.0 (LGPLv3).
174
-
175
- O pacote teve início no ano de **2022** como um pacote de pesquisa no instituto federal do norte de minas gerais - campus salinas (**IFNMG - Salinas**).
176
-
177
- Os sistemas imunológicos artificiais (SIA) inspiram-se no sistema imunológico dos vertebrados, criando metáforas que aplicam a capacidade de reconhecer e catalogar os patógenos, entre outras características desse sistema.
178
-
179
- ##### Algoritmos implementados:
180
-
181
- > - [x] [**Seleção Negativa.**](https://ais-package.github.io/docs/aisp-techniques/Negative%20Selection/)
182
- > - [ ] *Algoritmos de Seleção Clonal.*
183
- > - [ ] *Células Dendríticas.*
184
- > - [ ] *Teoria da Rede Imune.*
185
-
186
- </section>
187
-
188
- <section id='introdução'>
189
-
190
- #### **Instalação**
191
-
192
-
193
- O módulo requer a instalação do [python 3.8.10](https://www.python.org/downloads/) ou superior.
194
-
195
- <section id='dependências'>
196
-
197
- ##### **Dependências:**
198
- <div align = center>
199
-
200
- | Pacotes | Versão |
201
- |:-------------:|:-------------:|
202
- | numpy | ≥ 1.22.4 |
203
- | scipy | ≥ 1.8.1 |
204
- | tqdm | ≥ 4.64.1 |
205
-
206
- </div>
207
- </section>
208
-
209
- <section id='instalação-do-usuário'>
210
-
211
- ##### **Instalação do usuário**
212
-
213
- A maneira mais simples de instalação do AISP é utilizando o ``pip``:
214
-
215
- ```Bash
216
- pip install aisp
217
- ```
218
-
219
- </section>
220
-
221
- </section>
222
- <section id='exemplos'>
223
-
224
- #### Exemplos:
225
-
226
- ---
227
-
228
- ##### Exemplo utilizando a técnica de seleção negativa (**nsa**):
229
-
230
- No exemplo presente nesse [notebook](https://github.com/AIS-Package/aisp/blob/main/examples/RNSA/example_with_randomly_generated_dataset-pt.ipynb), gerando **500** amostras aleatórias dispostas em dois grupos um para cada classe.
231
-
232
- A seguir alguns exemplos que utiliza-se de base de dados para classificação com a ferramenta [Jupyter notebook](https://jupyter.org/).
233
-
234
- #### **Seleção Negativa:**
235
-
236
- + **RNSA** Aplicação das tecnica de seleção negativa para classificação utilizando a base de dados de flores da família Iris e Old Faithful Geyser:
237
- + [iris_dataBase_example](https://github.com/AIS-Package/aisp/blob/main/examples/RNSA/iris_dataBase_example_pt-br.ipynb)
238
- + [geyser_dataBase_example](https://github.com/AIS-Package/aisp/blob/main/examples/RNSA/geyser_dataBase_example_pt-br.ipynb)
239
-
240
- + **BNSA**
241
- + [mushrooms_dataBase_example](https://github.com/AIS-Package/aisp/blob/main/examples/BNSA/mushrooms_dataBase_example_en.ipynb)
242
-
243
-
244
- ---
245
-
246
146
  </section>
247
147
  </section>
@@ -0,0 +1,18 @@
1
+ aisp/__init__.py,sha256=pKOdkhFxWup_lhQPofFTk4rpqd0_IlYygHnkBhE2g2w,111
2
+ aisp/exceptions.py,sha256=ONiKCZrBhfUaMO1vYHnOr1_eL9PtVJ7b_HRroMbORpc,1405
3
+ aisp/base/__init__.py,sha256=rpb9ADmBtNpRAEJw61c7CsbZhHA2vGQOvjFmpk7w39c,100
4
+ aisp/base/_classifier.py,sha256=qv6TxzfnRwO7HvN7CA8PS1dueAnm-RifelRnCjrK9D0,3027
5
+ aisp/nsa/__init__.py,sha256=3-fSIJCMB_jcLGTr6DcVkloRfWyQJ8-JzD0CLhvpvgc,411
6
+ aisp/nsa/_base.py,sha256=cT404V5onduK19WW6ajxy_yUZha3Fk8KZJvJHt_UZBM,4250
7
+ aisp/nsa/_negative_selection.py,sha256=0_VI3rAeVzPcSRwjMjqCq6RT-1_a_-HCFtIIJL6jpyc,29582
8
+ aisp/nsa/_ns_core.py,sha256=VWt_L2ODXtngJ7BVmSVT7i7kK98axibOmCzbYCkjeqI,4934
9
+ aisp/utils/__init__.py,sha256=-r--qdfTq4dVJU-VoJ7dvXTNS5_I1q1aGAQ02zNBOGw,217
10
+ aisp/utils/_multiclass.py,sha256=t0RLIdUoUbvFL30a8XfO3BMXc8MimtLCHNbGCDL2BQk,1051
11
+ aisp/utils/distance.py,sha256=SZTE5KEB7QX9vKoY9GfFOfFGbswVhQM6-9baLq4ZXns,6304
12
+ aisp/utils/metrics.py,sha256=o6aD6qTLQtXhWNOMGjgweHMQ6SMQ2hh42NcSEmgY3RI,1292
13
+ aisp/utils/sanitizers.py,sha256=7wJSo5ZkRX1g16C9sEN8TWQ5l9Gzfl0-8CgLULnPNlk,1873
14
+ aisp-0.1.40.dist-info/licenses/LICENSE,sha256=fTqV5eBpeAZO0_jit8j4Ref9ikBSlHJ8xwj5TLg7gFk,7817
15
+ aisp-0.1.40.dist-info/METADATA,sha256=em8eJAx3lr87ZZ1ajsoSkIj-itauLz25E1FKcdjf1QU,4818
16
+ aisp-0.1.40.dist-info/WHEEL,sha256=GHB6lJx2juba1wDgXDNlMTyM13ckjBMKf-OnwgKOCtA,91
17
+ aisp-0.1.40.dist-info/top_level.txt,sha256=Q5aJi_rAVT5UNS1As0ZafoyS5dwNibnoyOYV7RWUB9s,5
18
+ aisp-0.1.40.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (80.3.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
aisp/NSA/__init__.py DELETED
@@ -1,18 +0,0 @@
1
- """Module (NSA) Negative Selection Algorithm
2
-
3
- NSAs simulate the maturation process of T-cells in the immune system, where these \
4
- cells learn to distinguish between self and non-self. Only T-cells capable \
5
- of recognizing non-self elements are preserved.
6
-
7
- ----
8
-
9
- Os NSAs simulam o processo de maturação das células-T no sistema imunológico, onde \
10
- essas células aprendem a distinguir entre o próprio e não-próprio.
11
- Apenas as células-T capazes de reconhecer elementos não-próprios são preservadas.
12
-
13
- """
14
- from ._negative_selection import BNSA, RNSA
15
-
16
- __author__ = "João Paulo da Silva Barros"
17
- __all__ = ["RNSA", "BNSA"]
18
- __version__ = "0.1.34"
aisp/NSA/_base.py DELETED
@@ -1,281 +0,0 @@
1
- from abc import abstractmethod
2
-
3
- import numpy as np
4
- import numpy.typing as npt
5
- from typing import Literal, Optional
6
- from scipy.spatial.distance import euclidean, cityblock, minkowski
7
-
8
- from ..utils.metrics import accuracy_score
9
-
10
-
11
- class Base:
12
- """
13
- The base class contains functions that are used by more than one class in the package, and \
14
- therefore are considered essential for the overall functioning of the system.
15
-
16
- ---
17
-
18
- A classe base contém funções que são utilizadas por mais de uma classe do pacote, e por isso \
19
- são consideradas essenciais para o funcionamento geral do sistema.
20
- """
21
-
22
- def __init__(self, metric: str = "euclidean", p: float = 2):
23
- """
24
- Parameters:
25
- ---
26
- * metric (``str``): Way to calculate the distance between the detector and the sample:
27
-
28
- * ``'Euclidean'`` ➜ The calculation of the distance is given by the expression: \
29
- √( (x₁ – x₂)² + (y₁ – y₂)² + ... + (yn – yn)²).
30
- * ``'minkowski'`` ➜ The calculation of the distance is given by the expression: \
31
- ( |X₁ – Y₁|p + |X₂ – Y₂|p + ... + |Xn – Yn|p) ¹/ₚ.
32
- * ``'manhattan'`` ➜ The calculation of the distance is given by the expression: \
33
- ( |x₁ – x₂| + |y₁ – y₂| + ... + |yn – yn|) .
34
-
35
-
36
- * p (``float``): This parameter stores the value of ``p`` used in the Minkowski distance.\
37
- The default is ``2``, which represents normalized Euclidean distance. Different \
38
- values of p lead to different variants of the Minkowski distance \
39
- [learn more](https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.minkowski.html).
40
-
41
- ---
42
-
43
- Parameters:
44
- ---
45
- * metric (``str``): Forma para se calcular a distância entre o detector e a amostra:
46
-
47
- * ``'euclidiana'`` ➜ O cálculo da distância dá-se pela expressão: \
48
- √( (x₁ – x₂)² + (y₁ – y₂)² + ... + (yn – yn)²).
49
- * ``'minkowski'`` ➜ O cálculo da distância dá-se pela expressão: \
50
- ( |X₁ – Y₁|p + |X₂ – Y₂|p + ... + |Xn – Yn|p).
51
- * ``'manhattan'`` ➜ O cálculo da distância dá-se pela expressão: \
52
- ( |x₁ – x₂| + |y₁ – y₂| + ... + |yn – yn|).
53
-
54
- Defaults to ``'euclidean'``.
55
-
56
- * p (``float``): Este parâmetro armazena o valor de ``p`` utilizada na distância de Minkowski. \
57
- O padrão é ``2``, o que significa distância euclidiana normalizada. Diferentes valores \
58
- de p levam a diferentes variantes da distância de Minkowski \
59
- [saiba mais](https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.minkowski.html).
60
- """
61
- if metric == "manhattan" or metric == "minkowski":
62
- self.metric: str = metric
63
- else:
64
- self.metric: str = "euclidean"
65
- self.p: float = p
66
-
67
- def _distance(self, u: npt.NDArray, v: npt.NDArray):
68
- """
69
- Function to calculate the distance between two points by the chosen ``metric``.
70
-
71
- Parameters:
72
- ---
73
- * u (``npt.NDArray``): Coordinates of the first point.
74
- * v (``npt.NDArray``): Coordinates of the second point.
75
-
76
- returns:
77
- ---
78
- * Distance (``double``) between the two points.
79
-
80
- ---
81
-
82
- Função para calcular a distância entre dois pontos pela ``metric`` escolhida.
83
-
84
- Parameters:
85
- ---
86
- * u (``npt.NDArray``): Coordenadas do primeiro ponto.
87
- * v (``npt.NDArray``): Coordenadas do segundo ponto.
88
-
89
- Returns:
90
- ---
91
- * Distância (``double``) entre os dois pontos.
92
- """
93
- if self.metric == "manhattan":
94
- return cityblock(u, v)
95
- elif self.metric == "minkowski":
96
- return minkowski(u, v, self.p)
97
- else:
98
- return euclidean(u, v)
99
-
100
- @staticmethod
101
- def _check_and_raise_exceptions_fit(
102
- X: npt.NDArray = None,
103
- y: npt.NDArray = None,
104
- _class_: Literal["RNSA", "BNSA"] = "RNSA",
105
- ):
106
- """
107
- Function responsible for verifying fit function parameters and throwing exceptions if the \
108
- verification is not successful.
109
-
110
- Parameters:
111
- ---
112
- * X (``npt.NDArray``): Training array, containing the samples and their characteristics, \
113
- [``N samples`` (rows)][``N features`` (columns)].
114
- * y (``npt.NDArray``): Array of target classes of ``X`` with [``N samples`` (lines)].
115
- * _class_ (Literal[RNSA, BNSA], optional): Current class. Defaults to 'RNSA'.
116
-
117
- Raises:
118
- ---
119
- * TypeError: If X or y are not ndarrays or have incompatible shapes.
120
- * ValueError: If _class_ is BNSA and X contains values that are not composed only of 0 and 1.
121
-
122
- ---
123
-
124
- Função responsável por verificar os parâmetros da função fit e lançar exceções se a \
125
- verificação não for bem-sucedida.
126
-
127
- Parâmetros:
128
- ---
129
- * X (``npt.NDArray``): Array de treinamento, contendo as amostras e suas características, \
130
- [``N samples`` (linhas)][``N features`` (colunas)].
131
- * y (``npt.NDArray``): Array de classes alvo de ``X`` com [``N samples`` (linhas)].
132
- * _class_ (Literal[RNSA, BNSA], opcional): Classe atual. O padrão é 'RNSA'.
133
-
134
- Lança:
135
- ---
136
- * TypeError: Se X ou y não forem ndarrays ou tiverem formas incompatíveis.
137
- * ValueError: Se _class_ for BNSA e X contiver valores que não sejam compostos apenas por 0 e 1.
138
- """
139
- if not isinstance(X, np.ndarray):
140
- if isinstance(X, list):
141
- X = np.array(X)
142
- else:
143
- raise TypeError("X is not an ndarray or list.")
144
- elif not isinstance(y, np.ndarray):
145
- if isinstance(y, list):
146
- y = np.array(y)
147
- else:
148
- raise TypeError("y is not an ndarray or list.")
149
- if X.shape[0] != y.shape[0]:
150
- raise TypeError(
151
- "X does not have the same amount of sample for the output classes in y."
152
- )
153
-
154
- if _class_ == "BNSA" and not np.isin(X, [0, 1]).all():
155
- raise ValueError(
156
- "The array X contains values that are not composed only of 0 and 1."
157
- )
158
-
159
- def score(self, X: npt.NDArray, y: list) -> float:
160
- """
161
- Score function calculates forecast accuracy.
162
-
163
- Details:
164
- ---
165
- This function performs the prediction of X and checks how many elements are equal between \
166
- vector y and y_predicted. This function was added for compatibility with some scikit-learn \
167
- functions.
168
-
169
- Parameters:
170
- -----------
171
-
172
- X: np.ndarray
173
- Feature set with shape (n_samples, n_features).
174
- y: np.ndarray
175
- True values with shape (n_samples,).
176
-
177
- Returns:
178
- -------
179
-
180
- accuracy: float
181
- The accuracy of the model.
182
-
183
- ---
184
-
185
- Função score calcular a acurácia da previsão.
186
-
187
- Details:
188
- ---
189
- Esta função realiza a previsão de X e verifica quantos elementos são iguais entre o vetor \
190
- y e y_previsto. Essa função foi adicionada para oferecer compatibilidade com algumas funções \
191
- do scikit-learn.
192
-
193
- Parameters:
194
- ---
195
-
196
- * X : np.ndarray
197
- Conjunto de características com shape (n_samples, n_features).
198
- * y : np.ndarray
199
- Valores verdadeiros com shape (n_samples,).
200
-
201
- returns:
202
- ---
203
-
204
- accuracy : float
205
- A acurácia do modelo.
206
- """
207
- if len(y) == 0:
208
- return 0
209
- y_pred = self.predict(X)
210
- return accuracy_score(y, y_pred)
211
-
212
- @abstractmethod
213
- def fit(self, X: npt.NDArray, y: npt.NDArray, verbose: bool = True):
214
- """
215
- Function to train the model using the input data ``X`` and corresponding labels ``y``.
216
-
217
- This abstract method is implemented by the class that inherits it.
218
-
219
- Parameters:
220
- ---
221
- * X (``npt.NDArray``): Input data used for training the model, previously normalized to the range [0, 1].
222
- * y (``npt.NDArray``): Corresponding labels or target values for the input data.
223
- * verbose (``bool``, optional): Flag to enable or disable detailed output during \
224
- training. Default is ``True``.
225
-
226
- Returns:
227
- ---
228
- * self: Returns the instance of the class that implements this method.
229
-
230
- ---
231
-
232
- Função para treinar o modelo usando os dados de entrada ``X`` e os classes correspondentes ``y``.
233
-
234
- Este método abstrato é implementado pela classe que o herdar.
235
-
236
- Parâmetros:
237
- ---
238
- * X (``npt.NDArray``): Dados de entrada utilizados para o treinamento do modelo, previamente \
239
- normalizados no intervalo [0, 1].
240
- * y (``npt.NDArray``): Rótulos ou valores-alvo correspondentes aos dados de entrada.
241
- * verbose (``bool``, opcional): Flag para ativar ou desativar a saída detalhada durante o \
242
- treinamento. O padrão é ``True``.
243
-
244
- Retornos:
245
- ---
246
- * self: Retorna a instância da classe que implementa este método.
247
- """
248
- pass
249
-
250
- @abstractmethod
251
- def predict(self, X) -> Optional[npt.NDArray]:
252
- """
253
- Function to generate predictions based on the input data ``X``.
254
-
255
- This abstract method is implemented by the class that inherits it.
256
-
257
- Parameters:
258
- ---
259
- * X (``npt.NDArray``): Input data for which predictions will be generated.
260
-
261
- Returns:
262
- ---
263
- * Predictions (``Optional[npt.NDArray]``): Predicted values for each input sample, or ``None``
264
- if the prediction fails.
265
-
266
- ---
267
-
268
- Função para gerar previsões com base nos dados de entrada ``X``.
269
-
270
- Este método abstrato é implementado pela classe que o herdar.
271
-
272
- Parâmetros:
273
- ---
274
- * X (``npt.NDArray``): Dados de entrada para os quais as previsões serão geradas.
275
-
276
- Retornos:
277
- ---
278
- * Previsões (``Optional[npt.NDArray]``): Valores previstos para cada amostra de entrada,
279
- ou ``None`` se a previsão falhar.
280
- """
281
- pass