Skip to content

Instantly share code, notes, and snippets.

@heiwang1997
heiwang1997 / nn.py
Last active July 20, 2020 05:23
Quick example on nearest neighbour in sklearn
from sklearn.neighbors import NearestNeighbors
import numpy as np
X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])
"""
Build a fast indexing data-structure.
:param algorithm: ['auto', 'ball_tree', 'kd_tree', 'brute']
- compared to kd_tree, ball_tree needs more time to build tree, but query fast for high-dim data.
:param n_neighbors: only effective when using 'kneighbors'
@heiwang1997
heiwang1997 / cloudSettings
Last active June 3, 2017 08:55
Visual Studio Code Settings Sync Gist
{"lastUpload":"2017-06-03T08:54:59.130Z","extensionVersion":"v2.8.1"}