glassbox.models.neighbors.index._base¶
Abstract BaseIndex interface for nearest-neighbor lookup.
BaseIndex
¶
Bases: ABC
Initialize the abstract index class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric
|
DistanceMetric
|
The distance metric to use. |
required |
Source code in glassbox/models/neighbors/index/_base.py
build
abstractmethod
¶
Build the index structure from the training data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Training data, shape (n_samples, n_features). |
required |
Source code in glassbox/models/neighbors/index/_base.py
query
abstractmethod
¶
Query the index for the k nearest neighbors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Query point(s), shape (n_features,) or (n_queries, n_features). |
required |
k
|
int
|
Number of nearest neighbors to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Indices of the k nearest neighbors. |