Skip to content

Instantly share code, notes, and snippets.

@yamaguchiyuto
Created June 21, 2013 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yamaguchiyuto/5831409 to your computer and use it in GitHub Desktop.
Save yamaguchiyuto/5831409 to your computer and use it in GitHub Desktop.
DBSCAN with scikit-learn
import numpy
from scipy.spatial import distance
from sklearn.cluster import DBSCAN
S = numpy.array([[0,0.9],[0.1,0.8],[0.9,0.1],[0.85,0.05],[0.9,0.05],[0.05,0.85],[0.5,0.4]])
dbs = DBSCAN(eps=0.2, min_samples=3)
dbs.fit(S)
dbs.labels_ # => array([ 1., 1., 0., 0., 0., 1., -1.])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment