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
16 changes: 12 additions & 4 deletions docs/advanced-guides/Utils/Distance.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def hamming(u: npt.NDArray, v: npt.NDArray) -> np.float64:

The function to calculate the normalized Hamming distance between two points.

$$\frac{(x_1 \neq y_1) + (x_2 \neq y_2) + \cdots + (x_n \neq y_n)}{n}$$
$$
\frac{(x_1 \neq y_1) + (x_2 \neq y_2) + \cdots + (x_n \neq y_n)}{n}
$$

**Parameters:**

Expand All @@ -37,7 +39,9 @@ def euclidean(u: npt.NDArray[np.float64], v: npt.NDArray[np.float64]) -> np.floa

Function to calculate the normalized Euclidean distance between two points.

$$\sqrt{(X_{1} - X_{1})^2 + (Y_{2} - Y_{2})^2 + \cdots + (Y_{n} - Y_{n})^2}$$
$$
\sqrt{(X_{1} - X_{1})^2 + (Y_{2} - Y_{2})^2 + \cdots + (Y_{n} - Y_{n})^2}
$$

**Parameters:**

Expand All @@ -58,7 +62,9 @@ def cityblock(u: npt.NDArray[np.float64], v: npt.NDArray[np.float64]) -> np.floa

Function to calculate the normalized Manhattan distance between two points.

$$\frac{(|X_{1} - X_{1}| + |Y_{2} - Y_{2}| + \cdots + |Y_{n} - Y_{n}|)}{n}$$
$$
\frac{(|X_{1} - X_{1}| + |Y_{2} - Y_{2}| + \cdots + |Y_{n} - Y_{n}|)}{n}
$$

**Parameters:**

Expand All @@ -79,7 +85,9 @@ def minkowski(u: npt.NDArray[np.float64], v: npt.NDArray[np.float64], p: float =

Function to calculate the normalized Minkowski distance between two points.

$$\frac{((|X_{1} - Y_{1}|^p + |X_{2} - Y_{2}|^p + \cdots + |X_{n} - Y_{n}|^p)^\frac{1}{p})}{n}$$
$$
\frac{((|X_{1} - Y_{1}|^p + |X_{2} - Y_{2}|^p + \cdots + |X_{n} - Y_{n}|^p)^\frac{1}{p})}{n}
$$

**Parameters:**

Expand Down
28 changes: 27 additions & 1 deletion docs/advanced-guides/Utils/Multiclass.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ author: João Paulo

This file contains internal utility functions designed to simplify data manipulation and processing in multiclass classification scenarios within the AISP package.

### def slice_index_list_by_class(...)
## def slice_index_list_by_class(...)

```python
def slice_index_list_by_class(classes: Union[npt.NDArray, list], y: npt.NDArray) -> dict
Expand All @@ -26,3 +26,29 @@ the output is the class being trained.
**returns**:

* dict: A dictionary with the list of array positions(``y``), with the classes as key.

---

## def predict_knn_affinity(...)

```python
def predict_knn_affinity(
X: npt.NDArray,
k: int,
all_cell_vectors: List[Tuple[Union[str, int], npt.NDArray]],
affinity_func: Callable[[npt.NDArray, npt.NDArray], float]
) -> npt.NDArray
```

Function to predict classes using k-nearest neighbors and trained cells.

**Parameters:**

* ***X*** (`npt.NDArray`): Input data to be classified.
* ***k*** (`int`): Number of nearest neighbors to consider for prediction.
* ***all_cell_vectors*** (`List[Tuple[Union[str, int], npt.NDArray]]`): List of tuples containing (class_name, cell vector) pairs.
* ***affinity_func*** (`Callable[[npt.NDArray, npt.NDArray], float]`): Function that takes two vectors and returns an affinity value.

**Returns:**

* `npt.NDArray`: Array of predicted labels for each sample in X, based on the k nearest neighbors.
17 changes: 17 additions & 0 deletions docs/advanced-guides/Utils/Random.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Random

Utility functions for random number generation and reproducibility.

## Function set_seed_numba(...)

```python
@njit(cache=True)
def set_seed_numba(seed: int)
```

Set the seed for random numbers used by functions compiled with Numba.

**Parameters**:

* **seed**: `int`
Integer value used to initialize Numba's random number generator.
81 changes: 78 additions & 3 deletions docs/advanced-guides/Utils/Validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,89 @@ This function analyzes the input vector and classifies its data as one of the su
* **continuous**: Float values within the normalized range `[0.0, 1.0]`.
* **ranged**: Float values outside the normalized range.

**Parameters**
### Parameters

* `vector` (`npt.NDArray`): An array containing the data to be classified.

**Returns**
### Returns

* `FeatureType` (`Literal["binary-features", "continuous-features", "ranged-features"]`): The detected type of data in the vector.

**Raises**
### Raises

* `UnsupportedDataTypeError`: Raised if the vector contains an unsupported data type.

---

## def check_array_type(...)

```python
def check_array_type(x, name: str = "X") -> npt.NDArray:
```

Ensure X is a numpy array. Convert from list if needed.

### Parameters

* `x` (`Any`): Array, containing the samples and their characteristics, \[`N samples` (rows)\]\[`N features` (columns)\].
* `name` (`str`, default='X'): Variable name used in error messages.

### Returns

* `npt.NDArray`: The converted or validated array.

### Raises

* `TypeError`: If X or y are not ndarrays or have incompatible shapes.

---

## def check_shape_match(...)

```python
def check_shape_match(x: npt.NDArray, y: npt.NDArray):
```

Ensure X and y have compatible first dimensions.

### Parameters

* `x` (`npt.NDArray`): Array, containing the samples and their characteristics, \[`N samples` (rows)\]\[`N features` (columns)\].
* `y` (`npt.NDArray`): Array of target classes of `x` with [`N samples` (lines)].

### Raises

* `TypeError`: If x or y are not ndarrays or have incompatible shapes.

---

## def check_feature_dimension(...)

```python
def check_feature_dimension(x: npt.NDArray, expected: int):
```

Ensure X has the expected number of features.

### Parameters

* `x` (`npt.NDArray`): Input array for prediction, containing the samples and their characteristics, \[`N samples` (rows)\]\[`N features` (columns)\].
* `expected` (`int`): Expected number of features per sample (columns in X).

### Raises

* `FeatureDimensionMismatch`: If the number of features in X does not match the expected number.

---

## def check_binary_array(...)

```python
def check_binary_array(x: npt.NDArray):
```

Ensure X contains only 0 and 1.

### Raises

* `ValueError`: If feature_type is binary-features and X contains values that are not composed only of 0 and 1.
5 changes: 0 additions & 5 deletions docs/advanced-guides/base-classes-reference/_category_.json

This file was deleted.

11 changes: 0 additions & 11 deletions docs/advanced-guides/base-classes-reference/csa/README.mdx

This file was deleted.

91 changes: 0 additions & 91 deletions docs/advanced-guides/base-classes-reference/csa/airs.md

This file was deleted.

11 changes: 0 additions & 11 deletions docs/advanced-guides/base-classes-reference/ina/README.mdx

This file was deleted.

Loading