frlearn.neighbours.neighbour_search.NNSearch

class frlearn.neighbours.neighbour_search.NNSearch(**kwargs)[source]

Abstract base class for nearest neighbour searches. Subclasses must implement __init__ and Index.

abstract __init__(self, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

class Index(search: frlearn.neighbours.neighbour_search.NNSearch, X)[source]

Abstract base class for the index object created by NNSearch.construct. Subclasses must implement __init__ and query.

Parameters
searchNNSearch

The search object that contains all the relevant parametre values.

Xarray shape=(n_instances, n_features, )

Construction instances.

abstract query(self, X, k: 'int')[source]

Identify the k nearest neighbours for each of the instances in X.

Parameters
Xarray shape=(n_instances, n_features, )

Query instances.

kint

Number of neighbours to return

Returns
Iarray shape=(n_instances, k, )

Indices of the k nearest neighbours among the construction instances for each query instance.

Darray shape=(n_instances, k, )

Distances to the k nearest neighbours among the construction instances for each query instance.

construct(self, X) → 'Index'[source]

Construct the index based on the data X.

Parameters
Xarray shape=(n_instances, n_features, )

Construction instances.

Returns
IIndex

Constructed index