pyFM.spectral.nearest_neighbor.brute_query¶
- pyFM.spectral.nearest_neighbor.brute_query(X, Y, k=1, return_distance=False, n_jobs=None, working_memory=None, **_)¶
Nearest neighbours by brute force. Best above a handful of dimensions.
Scikit learn uses nice mixed precision with memory handling.
- Parameters:
X (np.ndarray) – (n1, p). Reference points, the set being searched.
Y (np.ndarray) – (n2, p). Query points.
k (int) – Number of neighbours.
return_distance (bool) – Whether to also return distances.
n_jobs (int) – Passed through to scikit-learn.
working_memory (int, optional) – Chunking budget in MB. Defaults to the configured value.
- Returns:
dists (np.ndarray, optional) – (n2,) if k = 1 else (n2, k). Distance to each neighbour. Only if return_distance.
matches (np.ndarray) – (n2,) if k = 1 else (n2, k). Index in X of each neighbour.