Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
136 changes: 136 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
---
sidebar_position: 6
title: Frequently Asked Questions
sidebar_label: FAQ
keywords:
- FAQ
- Frequently Asked Questions
- Questions
- Help
---

Quick solutions for possible questions about aisp.

## General usage

### Which algorithm should I choose?

It depends on the type of problem:

- **Anomaly detection**: Use ``RNSA`` or ``BNSA``.
- RNSA for problems with continuous data.
- BNSA for problems with binary data.
- **Classification**: Use ``AIRS``, ``RNSA``, or ``BNSA``.
- ``RNSA`` and ``BNSA`` were implemented to be applied to multiclass classification.
- ``AIRS`` is more robust to noise in the data.
- **Optimization**: Use ``Clonalg``.
- The implementation can be applied to objective function optimization (min/max).
- **Clustering**: Use ``AiNet``.
- Automatically separates data into groups.
- Does not require a predefined number of clusters.

---

### How do I normalize my data to use the ``RNSA`` algorithm?

RNSA works exclusively with data normalized in the range [0, 1]. Therefore, before applying it, the data must be normalized if they are not already in this range. A simple way to do this is by using normalization tools from **scikit-learn**, such as [``MinMaxScaler``](https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.MinMaxScaler.html).

#### Example

In this example, ``X`` represents the non-normalized input data.

```python
from sklearn.preprocessing import MinMaxScaler

scaler = MinMaxScaler()

x_norm = scaler.fit_transform(X)

# Training the model with normalized data
rnsa = RNSA(N=100, r=0.1)
rnsa.fit(x_norm, y)
```

---

## Parameter configuration

### How do I choose the number of detectors (``N``) in ``RNSA`` or ``BNSA``?

The number of detectors directly affects performance:

- A small number of detectors may not adequately cover the non-self space.
- A very large number of detectors may increase training time and can cause overfitting.

**Recommendations**:

- Test different values for the number of detectors until you find a suitable balance between training time and model performance.
- Use cross-validation to identify the value that consistently yields the best results.

---

### Which radius (``r`` or ``aff_thresh``) should I use in ``BNSA`` or ``RNSA``?

The detector radius depends on the data distribution:

- A very small radius may fail to detect anomalies.
- A very large radius may overlap the self space and never generate valid detectors.

---

### What is the ``r_s`` parameter in ``RNSA``?

``r_s`` is the radius of the self sample. It defines a region around each training sample.

---

### Clonalg: How do I define the objective function?

The objective function must follow the pattern of the [base class](https://github.com/AIS-Package/aisp/blob/main/aisp/base/core/_optimizer.py#L140). It must receive a solution as input and return a cost (or affinity) value.

```python
def affinity_function(self, solution: Any) -> float:
pass
```

There are two ways to define the objective function in Clonalg.

1. Defining the function directly in the class constructor

```python
def sphere(solution):
return np.sum(solution *- 2)

clonalg = Clonalg(
problem_size=2,
affinity_function=sphere
)
```

2. Using the function registry

```python
def sphere(solution):
return np.sum(solution *- 2)

clonalg = Clonalg(
problem_size=2,
)

clonalg.register("affinity_function", sphere)
```

## Additional information

### Where can I find more examples?

- **[Examples in the documentation](./examples/)**.
- **[Examples on GitHub](https://github.com/AIS-Package/aisp/tree/main/examples)**

### How can I contribute to the project?

See the [Contribution Guide](https://github.com/AIS-Package/aisp/blob/main/CONTRIBUTING.md) on GitHub.

### Still have questions?

- Open an [**Issue on GitHub**](https://github.com/AIS-Package/aisp/issues)
20 changes: 19 additions & 1 deletion docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,29 @@ keywords:

</div>

<div style={{ display: "flex", justifyContent: "center", alignItems: "center", margin: "auto" }}>

[![GitHub stars](https://img.shields.io/github/stars/AIS-Package/aisp?style=social)](https://github.com/AIS-Package/aisp)
[![PyPI Downloads](https://static.pepy.tech/personalized-badge/aisp?period=total&units=INTERNATIONAL_SYSTEM&left_color=GRAY&right_color=GREEN&left_text=downloads)](https://pepy.tech/projects/aisp)
![License](https://img.shields.io/pypi/l/aisp)
![Python version](https://img.shields.io/pypi/pyversions/aisp)

</div>

---

## Introduction

**AISP** is a Python package of immunoinspired techniques that apply metaphors from the vertebrate immune system to pattern recognition and optimization tasks. Conceived as an open-source package of artificial immune systems, AISP emerged from a research project initiated in **2022** at the Instituto Federal do Norte de Minas Gerais - Campus Salinas (**IFNMG - Salinas**). Its distribution is governed by the GNU Lesser General Public License v3.0 (LGPLv3).
**AISP (Artificial Immune Systems Package)** is a Python package of immunoinspired techniques that apply metaphors from the vertebrate immune system to pattern recognition and optimization tasks. Conceived as an open-source package of artificial immune systems, AISP emerged from a research project initiated in **2022** at the Instituto Federal do Norte de Minas Gerais - Campus Salinas (**IFNMG - Salinas**). Its distribution is governed by the GNU Lesser General Public License v3.0 (LGPLv3).

### What can you do with AISP?

AISP provides implementations of bio-inspired algorithms for:

- **Anomaly detection**: Identify abnormal patterns in data.
- **Classification**: Classify data with multiple classes.
- **Optmization**: Find optimal solutions for objective functions.
- **Clustering**: Group data without supervision.

### Algorithms implemented

Expand Down
136 changes: 136 additions & 0 deletions i18n/pt-br/docusaurus-plugin-content-docs/current/faq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
---
sidebar_position: 6
title: Perguntas Frequentes
sidebar_label: FAQ
keywords:
- FAQ
- Perguntas Frequentes
- Dúvidas
- Ajuda
---

Soluções rápidas para possíveis duvidas sobre o aisp.

## Uso geral

### Qual algoritmo devo escolher?

Depende do tipo de problema:

- **Detecção de anomalias**: Use ``RNSA`` ou ``BNSA``.
- RNSA para problemas com dados contínuos.
- BNSA para problemas com dados binários.
- **Classificação**: Use ``AIRS``, ``RNSA`` ou ``BNSA``.
- O ``RNSA`` e ``BNSA``, foram implementados para serem aplicados a classificação multiclasse.
- O ``AIRS`` é mais robusto para ruídos nos dados.
- **Otimização**: Use ``Clonalg``.
- A implementação pode ser aplicada à otimização (min/max) de funções objetivas.
- **Clustering/Agrupamento**: Use ``AiNet``.
- Separa grupos de dados automaticamente.
- Não requer numero de grupos predefinidos.

---

### Como normalizar meus dados para utilizar o algoritmo ``RNSA``?

O RNSA trabalha exclusivamente com dados normalizados no intervalo entre [0, 1]. Portanto, antes de aplicá-lo, é necessário normalizar os dados se não estiver neste intervalo. Uma forma simples é fazer utilizando as ferramentas de normalização do **scikit-learn**, como o [``MinMaxScaler``](https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.MinMaxScaler.html).

#### Exemplo

Neste exemplo, ``X`` representa os dados de entrada não normalizados.

```python
from sklearn.preprocessing import MinMaxScaler

scaler = MinMaxScaler()

x_norm = scaler.fit_transform(X)

# Treinando o modelo com os dados normalizados.
rnsa = RNSA(N=100, r=0.1)
rnsa.fit(x_norm, y)
```

---

## Configuração de Parâmetros

### Como escolher o numero de detectores (``N``) no ``RNSA`` ou ``BNSA``?

O numero de detectores afeta diretamente a performance:

- Um número reduzido de detectores pode não cobrir adequadamente o espaço não-próprio.
- Um número muito alto de detectores pode aumentar o tempo de treinamento e pode causar overfitting.

**Recomendações**:

- Teste diferentes valores para o número de detectores até encontrar um equilíbrio adequado entre tempo de treinamento e desempenho do modelo.
- Utilize validação cruzada para identificar o valor que apresenta os melhores resultados de forma consistente.

---

### Qual raio (``r`` ou ``aff_thresh``) devo utilizar no ``BNSA`` ou ``RNSA``?

O raio dos detectores depende da distribuição dos dados:

- Raio muito pequeno, podem não detectar anomalias.
- Raio muito grandes, podem sobrepor o self e nunca gerar detectores validos.

---

### O que é o parâmetro ``r_s`` no ``RNSA``?

O ``r_s`` é o raio da amostra self. Ele define uma região ao redor de cada amostra de treinamento.

---

### Clonalg: Como definir a função objetivo?

A função objetiva deve seguir o padrão da [classe base](https://github.com/AIS-Package/aisp/blob/main/aisp/base/core/_optimizer.py#L140), Ela deve receber uma solução como entrada e retornar um valor do custo (ou afinidade).

```python
def affinity_function(self, solution: Any) -> float:
pass
```

Existem duas formas de definir a função objetivo no Clonalg.

1. Definindo a função diretamente no construtor da classe

```python
def sphere(solution):
return np.sum(solution ** 2)

clonalg = Clonalg(
problem_size=2,
affinity_function=sphere
)
```

2. Utilizando o registrador de funções

```python
def sphere(solution):
return np.sum(solution ** 2)

clonalg = Clonalg(
problem_size=2,
)

clonalg.register("affinity_function", sphere)
```

## Informações adicionais

### Onde encontrar mais exemplos?

- **[Exemplos na documentação](./examples/)**.
- **[Exemplos no github](https://github.com/AIS-Package/aisp/tree/main/examples)**

### Como contribuir para o projeto?

Veja o [Guia de Contribuição](https://github.com/AIS-Package/aisp/blob/main/CONTRIBUTING.md) no GitHub.

### Ainda tem dúvidas?

- Abra uma [**Issue no GitHub**](https://github.com/AIS-Package/aisp/issues)
19 changes: 18 additions & 1 deletion i18n/pt-br/docusaurus-plugin-content-docs/current/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,30 @@ keywords:

![Pacote de Sistemas Imunológicos Artificiais](./assets/logo.svg)

</div>
<div style={{ display: "flex", justifyContent: "center", alignItems: "center", margin: "auto" }}>

[![GitHub stars](https://img.shields.io/github/stars/AIS-Package/aisp?style=social)](https://github.com/AIS-Package/aisp)
[![PyPI Downloads](https://static.pepy.tech/personalized-badge/aisp?period=total&units=INTERNATIONAL_SYSTEM&left_color=GRAY&right_color=GREEN&left_text=downloads)](https://pepy.tech/projects/aisp)
![License](https://img.shields.io/pypi/l/aisp)
![Python version](https://img.shields.io/pypi/pyversions/aisp)

</div>

---

## Introdução

**AISP** é um pacote Python de técnicas imunoinspiradas, as quais aplicam metáforas do sistema imunológico dos vertebrados ao reconhecimento de padrões e à tarefas de otimização. Concebido como um pacote de sistemas imunológicos artificiais de código aberto, o AISP é resultado de um projeto de pesquisa iniciado em **2022** no Instituto Federal do Norte de Minas Gerais - Campus Salinas (**IFNMG - Salinas**). Sua distribuição é regida pela GNU Lesser General Public License v3.0 (LGPLv3).
**AISP (Artificial Immune Systems Package)** é um pacote Python de técnicas imunoinspiradas, as quais aplicam metáforas do sistema imunológico dos vertebrados ao reconhecimento de padrões e à tarefas de otimização. Concebido como um pacote de sistemas imunológicos artificiais de código aberto, o AISP é resultado de um projeto de pesquisa iniciado em **2022** no Instituto Federal do Norte de Minas Gerais - Campus Salinas (**IFNMG - Salinas**). Sua distribuição é regida pela GNU Lesser General Public License v3.0 (LGPLv3).

### O que voce pode fazer com o AISP?

O AISP oferece implementações de algoritmos bio-inspirados para:

- **Detecção de anomalias**: Identifique padrões anormais em dados.
- **Classificação**: Classifique dados com multi-classes.
- **Otimização**: Encontre soluções ótimas para funções objetivas.
- **Clustering**: Agrupe dados sem supervisão.

### Algoritmos implementados

Expand Down
Loading