Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
777337e
docs(template): Add documentation template for the class.
Joao-Paulo-Silva Feb 22, 2026
879ca97
docs(template): Add documentation template for the class.
Joao-Paulo-Silva Feb 22, 2026
07df1e6
docs(template): update documentation template.
Joao-Paulo-Silva Feb 22, 2026
1bd01ff
docs(base): adds the base module documentation in API format.
Joao-Paulo-Silva Feb 22, 2026
6e4656f
docs(template) update tags to keywords
Joao-Paulo-Silva Feb 22, 2026
1ffa1a3
docs(base): adds the mutation and populations documentation in API fo…
Joao-Paulo-Silva Feb 22, 2026
8a622f2
docs(base): adds the immune module to the documentation in API format
Joao-Paulo-Silva Mar 3, 2026
6df8072
docs(csa): adds AIRS API documentation
Joao-Paulo-Silva Mar 3, 2026
d1de1ee
docs: change the position of the references
Joao-Paulo-Silva Mar 3, 2026
542f370
docs(mutation): replaces <= and >= with special characters to avoid e…
Joao-Paulo-Silva Mar 3, 2026
11b91a4
docs(cell): adds descriptions of the standard methods lt, eq, and get…
Joao-Paulo-Silva Mar 3, 2026
df51306
docs(base): remove old version of docs already added
Joao-Paulo-Silva Mar 3, 2026
9457cec
docs(csa): adds API documentation for clonalg
Joao-Paulo-Silva Mar 3, 2026
038c941
docs(csa): adds API documentation for AiNet
Joao-Paulo-Silva Mar 3, 2026
7bdcb37
docs(csa): adds API documentation Readme for csa and ina.
Joao-Paulo-Silva Mar 3, 2026
3640ada
docs(csa): adds API documentation for nsa module
Joao-Paulo-Silva Mar 3, 2026
4cbdbee
docs: add tags to the class documentation
Joao-Paulo-Silva Mar 5, 2026
7bf7fc9
docs: adds initial readme to the API documentation
Joao-Paulo-Silva Mar 5, 2026
ac53ab0
docs: adds initial readme to the API documentation
Joao-Paulo-Silva Mar 5, 2026
e332800
docs(template): add templates for modules and modules with only function
Joao-Paulo-Silva Mar 9, 2026
0318575
docs(utils): Add documentation for the display and distance modules.
Joao-Paulo-Silva Mar 9, 2026
86146fa
docs(utils): Add documentation for the metrics, multiclass and saniti…
Joao-Paulo-Silva Mar 9, 2026
da9fbec
docs(utils): Add documentation for the types modules.
Joao-Paulo-Silva Mar 9, 2026
31a1cfd
docs(utils): Add documentation for the validation modules.
Joao-Paulo-Silva Mar 9, 2026
70de0b1
docs(utils): Add documentation.
Joao-Paulo-Silva Mar 9, 2026
9d3d884
fix(docs): corrects documentation compatibility with docusaurus.
Joao-Paulo-Silva Mar 9, 2026
47a1efe
docs: remove old documentation in Portuguese
Joao-Paulo-Silva Mar 9, 2026
d525792
feat: add example to accuracy_score docstring
Joao-Paulo-Silva Mar 13, 2026
90de5ac
docs(exceptions): add documentation for exceptions class parameters
Joao-Paulo-Silva Mar 13, 2026
cd183be
docs(exceptions): add documentation for exceptions in the api
Joao-Paulo-Silva Mar 13, 2026
173db14
docs(exceptions): add documentation for exceptions in the api
Joao-Paulo-Silva Mar 13, 2026
e198a4d
docs(cell): adds pt-br documentation for Cell in the API
Joao-Paulo-Silva Mar 14, 2026
aa344de
docs(cell): adds pt-br documentation for immune in the API
Joao-Paulo-Silva Mar 14, 2026
ceb3c35
docs(cell): adds pt-br documentation for base in the API
Joao-Paulo-Silva Mar 15, 2026
dc6dc64
docs: update docs
Joao-Paulo-Silva Mar 16, 2026
2df35f2
docs: fix auto lint
Joao-Paulo-Silva Mar 16, 2026
9a591bf
refactor: use only "`" for inline code blocks.
Joao-Paulo-Silva Mar 16, 2026
4626eff
feat: update templates to use tables for return and raises sections
Joao-Paulo-Silva Mar 21, 2026
eeaac9a
docs: update Raises section in docstrings
Joao-Paulo-Silva Mar 21, 2026
77df0c9
docs(api-en): update Raises e returns section in docs.
Joao-Paulo-Silva Mar 21, 2026
1b23622
docs(faq): adds faq to aisp documentation
Joao-Paulo-Silva Mar 24, 2026
3b45ea0
docs(pt-br): update docs api for the new returns and exceptions model.
Joao-Paulo-Silva Mar 25, 2026
46cd33d
docs(pt-br): update docs api for the new returns and exceptions model.
Joao-Paulo-Silva Mar 25, 2026
c399cd0
docs(pt-br): adds pt-br documentation for the CSA module to the api.
Joao-Paulo-Silva Mar 26, 2026
fdd90e7
docs(pt-br): adds pt-br documentation for the INA module to the api.
Joao-Paulo-Silva Mar 28, 2026
48113ea
docs(pt-br): adds pt-br documentation for the NSA module to the api.
Joao-Paulo-Silva Mar 29, 2026
ed93602
docs(pt-br): adds pt-br documentation for the exceptions module to th…
Joao-Paulo-Silva Mar 29, 2026
91ba110
docs(pt-br): adds pt-br documentation for the utils module to the api.
Joao-Paulo-Silva Mar 29, 2026
5b7280e
docs: improve the description of the x and y parameters in the fit an…
Joao-Paulo-Silva Mar 29, 2026
ff88e01
docs: adds aisp architecture documentation
Joao-Paulo-Silva Apr 3, 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
16 changes: 8 additions & 8 deletions aisp/base/core/_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ def fit(
Parameters
----------
X : Union[npt.NDArray, list]
Input data used for training the model.
Training input samples. Each row corresponds to a samples and column to feature.
y : Union[npt.NDArray, list]
Corresponding labels or target values for the input data.
Target vector of shape (n_samples,). Must contain the same number of samples as `X`.
verbose : bool, default=True
Flag to enable or disable detailed output during training.
If True, prints training progress information.

Returns
-------
Expand All @@ -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.
Input samples. Must have the same number of features used during training.

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)
10 changes: 5 additions & 5 deletions aisp/base/core/_clusterer.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ def fit(self, X: Union[npt.NDArray, list], verbose: bool = True) -> BaseClustere
Parameters
----------
X : Union[npt.NDArray, list]
Input data used for training the model.
Training input samples. Each row corresponds to a samples and column to feature.
verbose : bool, default=True
Flag to enable or disable detailed output during training.
If True, prints training progress information.

Returns
-------
Expand All @@ -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.
Input samples. Must have the same number of features used during training.

Returns
-------
Expand All @@ -87,9 +87,9 @@ 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.
Training input samples. Each row corresponds to a samples and column to feature.
verbose : bool, default=True
Flag to enable or disable detailed output during training.
If True, prints training progress information.

Returns
-------
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
46 changes: 28 additions & 18 deletions aisp/csa/_ai_recognition_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,15 @@ 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.
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 @@ -105,7 +104,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 @@ -173,23 +172,27 @@ 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
----------
X : Union[npt.NDArray, list]
Training array, containing the samples and their characteristics,
Shape: (n_samples, n_features).
Training input samples. Each row corresponds to a samples and column to feature.
y : Union[npt.NDArray, list]
Array of target classes of ``X`` with (``n_samples``).
verbose : bool
Feedback on which sample aᵢ the memory cells are being generated.
Target vector of shape (n_samples,). Must contain the same number of samples as `X`.
verbose : bool, default=True
If True, prints training progress information.

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 @@ -256,7 +259,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``)
Input samples. Must have the same number of features used during training.

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

Raises
------
Expand All @@ -267,12 +276,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 @@ -522,6 +525,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
Loading
Loading