FAISS Wrapper

class deslib.util.faiss_knn_wrapper.FaissKNNClassifier(n_neighbors=5, n_jobs=None, algorithm=None)[source]

Faiss KNN wrapper.

Parameters:
n_neighbors : int (Default = 5)

Number of neighbors used in the nearest neighbor search.

n_jobs : int (Default = None)
The number of jobs to run in parallel for both fit and predict.

If -1, then the number of jobs is set to the number of cores.

algorithm : str (Default = None)

Algorithm used for nearest

References

Johnson Jeff, Matthijs Douze, and Hervé Jégou. “Billion-scale similarity search with gpus.” arXiv preprint arXiv:1702.08734 (2017).

fit(X, y)[source]

Fit the model according to the given training data.

Parameters:
X : array of shape = [n_samples, n_features]

Data used to fit the model.

y : array of shape = [n_samples]

class labels of each example in X.

kneighbors(X, n_neighbors=None, return_distance=True)[source]

Finds the K-neighbors of a point.

Parameters:
X : array of shape = [n_samples, n_features]

The input data.

n_neighbors : int

Number of neighbors to get (default is the value passed to the constructor).

return_distance : boolean, optional. Defaults to True.

If False, distances will not be returned

Returns:
dists : list of shape = [n_samples, k]

The distances between the query and each sample in the region of competence. The vector is ordered in an ascending fashion.

idx : list of shape = [n_samples, k]

Indices of the instances belonging to the region of competence of the given query sample.

predict(X)[source]

Predict the class label for each sample in X.

Parameters:
X : array of shape = [n_samples, n_features]

The input data.

Returns:
preds : array, shape (n_samples,)

Class labels for samples in X.

predict_proba(X)[source]

Estimates the posterior probabilities for sample in X.

Parameters:
X : array of shape = [n_samples, n_features]

The input data.

Returns:
preds_proba : array of shape = [n_samples, n_classes]

Probabilities estimates for each sample in X.