Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
95c0302
docs(template): Add documentation template for the class.
Joao-Paulo-Silva Feb 22, 2026
a1c7b84
docs(template): Add documentation template for the class.
Joao-Paulo-Silva Feb 22, 2026
1705be9
docs(template): update documentation template.
Joao-Paulo-Silva Feb 22, 2026
0115501
docs(base): adds the base module documentation in API format.
Joao-Paulo-Silva Feb 22, 2026
37de9ec
docs(template) update tags to keywords
Joao-Paulo-Silva Feb 22, 2026
7ade1fa
docs(base): adds the mutation and populations documentation in API fo…
Joao-Paulo-Silva Feb 22, 2026
8dc5d33
docs(base): adds the immune module to the documentation in API format
Joao-Paulo-Silva Mar 3, 2026
aecbe44
docs(csa): adds AIRS API documentation
Joao-Paulo-Silva Mar 3, 2026
8b6eecf
docs: change the position of the references
Joao-Paulo-Silva Mar 3, 2026
5f38f38
docs(mutation): replaces <= and >= with special characters to avoid e…
Joao-Paulo-Silva Mar 3, 2026
8672ca5
docs(cell): adds descriptions of the standard methods lt, eq, and get…
Joao-Paulo-Silva Mar 3, 2026
f5f6fdf
docs(base): remove old version of docs already added
Joao-Paulo-Silva Mar 3, 2026
70e195b
docs(csa): adds API documentation for clonalg
Joao-Paulo-Silva Mar 3, 2026
19b2332
docs(csa): adds API documentation for AiNet
Joao-Paulo-Silva Mar 3, 2026
a93fd2d
docs(csa): adds API documentation Readme for csa and ina.
Joao-Paulo-Silva Mar 3, 2026
4da5c68
docs(csa): adds API documentation for nsa module
Joao-Paulo-Silva Mar 3, 2026
bf946da
docs: add tags to the class documentation
Joao-Paulo-Silva Mar 5, 2026
90963f2
docs: adds initial readme to the API documentation
Joao-Paulo-Silva Mar 5, 2026
f5b9697
docs: adds initial readme to the API documentation
Joao-Paulo-Silva Mar 5, 2026
96b521e
docs(template): add templates for modules and modules with only function
Joao-Paulo-Silva Mar 9, 2026
92860ef
docs(utils): Add documentation for the display and distance modules.
Joao-Paulo-Silva Mar 9, 2026
b2da15d
docs(utils): Add documentation for the metrics, multiclass and saniti…
Joao-Paulo-Silva Mar 9, 2026
67cb484
docs(utils): Add documentation for the types modules.
Joao-Paulo-Silva Mar 9, 2026
66e5f8d
docs(utils): Add documentation for the validation modules.
Joao-Paulo-Silva Mar 9, 2026
d30469d
docs(utils): Add documentation.
Joao-Paulo-Silva Mar 9, 2026
0a4c321
fix(docs): corrects documentation compatibility with docusaurus.
Joao-Paulo-Silva Mar 9, 2026
a489dbb
docs: remove old documentation in Portuguese
Joao-Paulo-Silva Mar 9, 2026
ab4fb0a
feat: add example to accuracy_score docstring
Joao-Paulo-Silva Mar 13, 2026
bdd9fa1
docs(exceptions): add documentation for exceptions class parameters
Joao-Paulo-Silva Mar 13, 2026
57b3158
docs(exceptions): add documentation for exceptions in the api
Joao-Paulo-Silva Mar 13, 2026
2cbb35c
docs(exceptions): add documentation for exceptions in the api
Joao-Paulo-Silva Mar 13, 2026
e87e083
docs(cell): adds pt-br documentation for Cell in the API
Joao-Paulo-Silva Mar 14, 2026
d5d2cba
docs(cell): adds pt-br documentation for immune in the API
Joao-Paulo-Silva Mar 14, 2026
6415d92
docs(cell): adds pt-br documentation for base in the API
Joao-Paulo-Silva Mar 15, 2026
e8378cd
docs: update docs
Joao-Paulo-Silva Mar 16, 2026
e06a337
docs: fix auto lint
Joao-Paulo-Silva Mar 16, 2026
7750b8b
refactor: use only "`" for inline code blocks.
Joao-Paulo-Silva Mar 16, 2026
9cf2fd4
feat: update templates to use tables for return and raises sections
Joao-Paulo-Silva Mar 21, 2026
6c42674
docs: update Raises section in docstrings
Joao-Paulo-Silva Mar 21, 2026
c5e81d1
docs(api-en): update Raises e returns section in docs.
Joao-Paulo-Silva Mar 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aisp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
from . import nsa

__author__ = "AISP Development Team"
__version__ = "0.5.1"
__version__ = "0.5.4"
__all__ = ["csa", "nsa", "ina"]
10 changes: 5 additions & 5 deletions aisp/base/core/_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def predict(self, X: Union[npt.NDArray, list]) -> npt.NDArray:
Parameters
----------
X : Union[npt.NDArray, list]
Input data for which predictions will be generated.
Data for which predictions will be generated.

Returns
-------
Expand All @@ -83,8 +83,8 @@ def score(
"""
Score function calculates forecast accuracy.

Details
-------
Notes
-----
This function performs the prediction of X and checks how many elements are equal
between vector y and y_predicted. This function was added for compatibility with some
scikit-learn functions.
Expand Down Expand Up @@ -116,11 +116,11 @@ def _slice_index_list_by_class(self, y: npt.NDArray) -> dict:
Parameters
----------
y : npt.NDArray
Receives a y ``n_samples`` array with the output classes of the ``X`` sample array.
Receives a y `n_samples` array with the output classes of the `X` sample array.

Returns
-------
indices_by_class : dict
A dictionary with the list of array positions(``y``), with the classes as key.
A dictionary with the list of array positions(`y`), with the classes as key.
"""
return slice_index_list_by_class(self.classes, y)
4 changes: 2 additions & 2 deletions aisp/base/core/_clusterer.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def predict(self, X: Union[npt.NDArray, list]) -> npt.NDArray:
Parameters
----------
X : Union[npt.NDArray, list]
Input data for which predictions will be generated.
Data for which predictions will be generated.

Returns
-------
Expand All @@ -87,7 +87,7 @@ def fit_predict(self, X: Union[npt.NDArray, list], verbose: bool = True) -> npt.
Parameters
----------
X : Union[npt.NDArray, list]
Input data for which predictions will be generated.
Data for which predictions will be generated.
verbose : bool, default=True
Flag to enable or disable detailed output during training.

Expand Down
15 changes: 10 additions & 5 deletions aisp/base/core/_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ def optimize(
def affinity_function(self, solution: Any) -> float:
"""Evaluate the affinity of a candidate solution.

This abstract method must be implemented by the subclass to define the problem-specific.
This method must be implemented according to the specific optimization problem, defining
how the solution will be evaluated. The returned value should represent the quality of
the evaluated solution.

Parameters
----------
Expand All @@ -186,10 +188,10 @@ def register(self, alias: str, function: Callable[..., Any]) -> None:
Raises
------
TypeError
If `function` is not callable.
If the provided `function` is not callable.
AttributeError
If `alias` is protected and cannot be modified. Or if `alias` does not exist in the
optimizer class.
If `alias` is protected and cannot be modified, or does not exist in the
class.
"""
if not callable(function):
raise TypeError(f"Expected a function for '{alias}', got {type(function).__name__}")
Expand All @@ -202,7 +204,10 @@ def register(self, alias: str, function: Callable[..., Any]) -> None:
setattr(self, alias, function)

def reset(self):
"""Reset the object's internal state, clearing history and resetting values."""
"""Reset the object's internal state.

Clears the optimization history and resetting values.
"""
self._cost_history = []
self._solution_history = []
self._best_solution = None
Expand Down
6 changes: 3 additions & 3 deletions aisp/base/immune/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ def hyper_clonal_mutate(
bounds: Optional[npt.NDArray[np.float64]] = None
) -> npt.NDArray:
"""
Clones N features from a cell's features, generating a set of mutated vectors.
Generate N clones of the current cell and apply hypermutation to the clones.

Parameters
----------
n : int
Number of clones to be generated from mutations of the original cell.
Number of clones to generate from the original b-cell.
feature_type : { "binary-features", "continuous-features", "ranged-features" }
Specifies the type of feature_type to use based on the nature of the input features
Specifies the type of features of the cell.
bounds : npt.NDArray[np.float64], optional
Array (n_features, 2) with min and max per dimension.

Expand Down
34 changes: 14 additions & 20 deletions aisp/base/immune/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ def clone_and_mutate_continuous(
"""
Generate a set of mutated clones from a cell represented by a continuous vector.

This function creates `n` clones of the input vector and applies random mutations to each of
them, simulating the process of clonal expansion in artificial immune systems. Each clone
will have a random number of mutations applied in distinct positions of the original vector.
This function creates `n` clones of the input vector and applies mutations to each of
them, simulating the process of clonal expansion in artificial immune systems.

Parameters
----------
Expand All @@ -30,9 +29,8 @@ def clone_and_mutate_continuous(
n : int
The number of mutated clones to be generated.
mutation_rate : float, default=1
If 0 <= mutation_rate < 1: probability of mutating each component.
If mutation_rate >= 1 or mutation_rate <= 0: the mutation randomizes
a number of components between 1 and len(vector).
If 0 ≤ mutation_rate < 1, mutation probability per feature.
Otherwise, a random number of features is mutated.

Returns
-------
Expand Down Expand Up @@ -67,9 +65,8 @@ def clone_and_mutate_binary(
"""
Generate a set of mutated clones from a cell represented by a binary vector.

This function creates `n` clones of the input vector and applies random mutations to each of
them, changing some bits randomly. The process simulates clonal expansion in artificial
immune systems with discrete representations.
This function creates `n` clones of the input binary vector and applies mutations to the
bits, simulating clonal expansion in artificial immune systems with discrete representations.

Parameters
----------
Expand All @@ -78,9 +75,8 @@ def clone_and_mutate_binary(
n : int
The number of mutated clones to be generated.
mutation_rate : float, default=1
If 0 <= mutation_rate < 1: probability of mutating each component.
If mutation_rate >= 1 or mutation_rate <= 0: the mutation randomizes
a number of components between 1 and len(vector).
If 0 ≤ mutation_rate < 1, mutation probability per feature.
Otherwise, a random number of features is mutated.

Returns
-------
Expand Down Expand Up @@ -116,9 +112,8 @@ def clone_and_mutate_ranged(
"""
Generate a set of mutated clones from a cell represented by custom ranges per dimension.

This function creates `n` clones of the input vector and applies random mutations to each of
them, simulating the process of clonal expansion in artificial immune systems. Each clone
will have a random number of mutations applied in distinct positions of the original vector.
This function creates `n` clones of the input vector and applies mutations to each of
them, simulating the process of clonal expansion in artificial immune systems.

Parameters
----------
Expand All @@ -129,9 +124,8 @@ def clone_and_mutate_ranged(
bounds : np.ndarray
Array (n_features, 2) with min and max per dimension.
mutation_rate : float, default=1
If 0 <= mutation_rate < 1: probability of mutating each component.
If mutation_rate >= 1 or mutation_rate <= 0: the mutation randomizes
a number of components between 1 and len(vector).
If 0 ≤ mutation_rate < 1, mutation probability per feature.
Otherwise, a random number of features is mutated.

Returns
-------
Expand Down Expand Up @@ -166,7 +160,7 @@ def clone_and_mutate_permutation(
n: int,
mutation_rate: float
) -> npt.NDArray[np.int64]:
"""Generate a set of mutated clones by random permutation.
"""Generate a set of mutated clones by permutation.

Parameters
----------
Expand All @@ -175,7 +169,7 @@ def clone_and_mutate_permutation(
n : int
The number of mutated clones to be generated.
mutation_rate : float
Probability of mutating each component 0 <= mutation_rate < 1.
Probability of mutating each feature 0 mutation_rate < 1.

Returns
-------
Expand Down
12 changes: 6 additions & 6 deletions aisp/base/immune/populations.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ def generate_random_antibodies(
Number of antibodies (samples) to generate.
n_features : int
Number of features (dimensions) for each antibody.
feature_type : FeatureType, default="continuous-features"
feature_type : FeatureTypeAll, default="continuous-features"
Specifies the type of features: "continuous-features", "binary-features",
"ranged-features", or "permutation-features".
bounds : npt.NDArray[np.float64], optional
Array (n_features, 2) with min and max per dimension.

Raises
------
ValueError
If number of features must be greater than zero.

Returns
-------
npt.NDArray
Array of shape (n_samples, n_features) containing the generated antibodies.

Raises
------
ValueError
If the number of features is less than or equal to zero.
"""
if n_features <= 0:
raise ValueError("Number of features must be greater than zero.")
Expand Down
39 changes: 25 additions & 14 deletions aisp/csa/_ai_recognition_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,17 @@ class AIRS(BaseClassifier):
k : int, default=3
The number of K nearest neighbors that will be used to choose a label in the prediction.
max_iters : int, default=100
Maximum number of interactions in the refinement process of the ARB set exposed to aᵢ.
Maximum number of iterations in the refinement process of the ARB set exposed to aᵢ.
resource_amplified : float, default=1.0
Resource consumption amplifier is multiplied with the incentive to subtract resources.
Defaults to 1.0 without amplification.
metric : {"euclidean", "minkowski", "manhattan"}, default="euclidean"
Distance metric used to compute affinity between cells and samples.
seed : int
Seed for the random generation of detector values. Defaults to None.
Seed for random generation.

**kwargs
p : float
This parameter stores the value of ``p`` used in the Minkowski distance. The default
This parameter stores the value of `p` used in the Minkowski distance. The default
is ``2``, which represents normalized Euclidean distance.\
Different values of p lead to different variants of the Minkowski Distance.

Expand Down Expand Up @@ -107,7 +106,7 @@ class AIRS(BaseClassifier):
>>> airs = airs.fit(x_train, y_train, verbose=False)
>>> x_test = [
... [0.15, 0.45], # Expected: Class 0
... [0.85, 0.65], # Esperado: Classe 1
... [0.85, 0.65], # Esperado: Class 1
... ]
>>> y_pred = airs.predict(x_test)
>>> print(y_pred)
Expand Down Expand Up @@ -175,7 +174,7 @@ def fit(
"""
Fit the model to the training data using the AIRS.

The function ``fit(...)``, performs the training according to ``X`` and ``y``, using the
The function ``fit(...)``, performs the training according to `X` and `y`, using the
method AIRS.

Parameters
Expand All @@ -184,14 +183,19 @@ def fit(
Training array, containing the samples and their characteristics,
Shape: (n_samples, n_features).
y : Union[npt.NDArray, list]
Array of target classes of ``X`` with (``n_samples``).
Array of target classes of `X` with (`n_samples`).
verbose : bool
Feedback on which sample aᵢ the memory cells are being generated.

Returns
-------
AIRS
Returns the instance itself.

Raises
------
TypeError
If X or y are not ndarrays or have incompatible shapes.
"""
X = self._prepare_features(X)
y = check_array_type(y, "y")
Expand Down Expand Up @@ -258,7 +262,13 @@ def predict(self, X: Union[npt.NDArray, list]) -> npt.NDArray:
Parameters
----------
X : Union[npt.NDArray, list]
Array with input samples with Shape: (``n_samples, n_features``)
Array with input samples with Shape: (`n_samples, n_features`)

Returns
-------
C : npt.NDArray
An ndarray of the form `C` (`n_samples`), containing the predicted classes for
`X`.

Raises
------
Expand All @@ -269,12 +279,6 @@ def predict(self, X: Union[npt.NDArray, list]) -> npt.NDArray:
ModelNotFittedError
If the mode has not yet been adjusted and does not have defined memory cells, it is
not able to predictions

Returns
-------
C : npt.NDArray
An ndarray of the form ``C`` (``n_samples``), containing the predicted classes for
``X``.
"""
if self._all_class_cell_vectors is None:
raise ModelNotFittedError("AIRS")
Expand Down Expand Up @@ -524,6 +528,13 @@ def _prepare_features(self, X: Union[npt.NDArray, list]) -> npt.NDArray:
-------
X : npt.NDArray
The processed input data.

Raises
------
TypeError:
If X is not a ndarray or a list.
UnsupportedTypeError
If the data type of the vector is not supported.
"""
X = check_array_type(X)
self._feature_type = detect_vector_data_type(X)
Expand Down
14 changes: 7 additions & 7 deletions aisp/csa/_clonalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Clonalg(BaseOptimizer):
Dimension of the problem to be minimized.
N : int, default=50
Number of memory cells (antibodies) in the population.
rate_clonal : float, default=10
rate_clonal : int, default=10
Maximum number of possible clones of a cell. This value is multiplied by
cell_affinity to determine the number of clones.
rate_hypermutation : float, default=1.0
Expand Down Expand Up @@ -182,19 +182,19 @@ def optimize(
max_iters : int, default=50
Maximum number of iterations when searching for the best solution using clonalg.
n_iter_no_change: int, default=10
The maximum number of iterations without updating the best cell
The maximum number of iterations without updating the best cell.
verbose : bool, default=True
Feedback on iterations, indicating the best antibody.

Raises
------
NotImplementedError
If no affinity function has been provided to model.

Returns
-------
population : List[Antibody]
Antibody population after clonal expansion.

Raises
------
NotImplementedError
If no affinity function has been provided to evaluate candidate solutions.
"""
self.reset()

Expand Down
Loading
Loading