Skip to content
forked from sohlich/go-dbscan

Implementation of DBSCAN clustering algorithm in Golang

License

Notifications You must be signed in to change notification settings

kelindar/dbscan

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DBSCAN in Go

Go Report Card GoDoc

This package implements density-based spatial clustering of applications with noise DBSCAN in Golang. It is a data clustering algorithm proposed by Martin Ester, Hans-Peter Kriegel, Jörg Sander and Xiaowei Xu in 1996 which clusters densely packed points. This particular implementation is a fork of sohlich/go-dbscan with few optimizations and some clean up to make it a bit more idiomatic.

Usage

In order to use it, a point needs to implement DistanceTo and Name functions.

type Value float64

func (v Value) DistanceTo(other dbscan.Point) float64 {
	return math.Abs(float64(other.(Value)) - v)
}

func (v Value) Name() string {
	return fmt.Sprint(v)
}

After this, dbscan.Cluster function can be called with a list of points, desired minimum density and epsilon value.

clusters := dbscan.Cluster(2,  1.0,
    Value(1),
    Value(0.5),
    Value(0),
    Value(5),
    Value(4.5),
    Value(4),
)