go-dbscan: bitbucket.org/sjbog/go-dbscan Index | Files

package dbscan

import "bitbucket.org/sjbog/go-dbscan"

DBSCAN (Density-based spatial clustering) clustering optimized for multicore processing.

Usage example:

var clusterer = NewDBSCANClusterer( 2.0, 2 )

var data = []ClusterablePoint{
		&NamedPoint{"0", []float64{2, 4}},
		&NamedPoint{"1", []float64{7, 3}},
		&NamedPoint{"2", []float64{3, 5}},
		&NamedPoint{"3", []float64{5, 3}},
		&NamedPoint{"4", []float64{7, 4}},
	}

clusterer.MinPts = 2
clusterer.SetEps( 2.0 )

// Automatic discovery of dimension with max variance
clusterer.AutoSelectDimension = false
// Set dimension manually
clusterer.SortDimensionIndex = 1

var result  [][]ClusterablePoint = clusterer.Cluster(data)

Index

Package Files

DBSCANclusterer.go clusterablePoint.go concurrentQueue.go

func Variance Uses

func Variance(data []ClusterablePoint, dimension int) float64

type ClusterablePoint Uses

type ClusterablePoint interface {
    GetPoint() []float64
    String() string
}

func NamedPointToClusterablePoint Uses

func NamedPointToClusterablePoint(in []*NamedPoint) (out []ClusterablePoint)

type ClusterablePointSlice Uses

type ClusterablePointSlice struct {
    Data          []ClusterablePoint
    SortDimension int
}

Slice attaches the methods of Interface to []float64, sorting in increasing order.

func (ClusterablePointSlice) Len Uses

func (self ClusterablePointSlice) Len() int

func (ClusterablePointSlice) Less Uses

func (self ClusterablePointSlice) Less(i, j int) bool

func (ClusterablePointSlice) Sort Uses

func (self ClusterablePointSlice) Sort()

Sort is a convenience method.

func (ClusterablePointSlice) Swap Uses

func (self ClusterablePointSlice) Swap(i, j int)

type Clusterer Uses

type Clusterer interface {
    Cluster([]ClusterablePoint) [][]ClusterablePoint
}

type ConcurrentQueue_InsertOnly Uses

type ConcurrentQueue_InsertOnly struct {
    Head unsafe.Pointer
    Size uint64
}

func NewConcurrentQueue_InsertOnly Uses

func NewConcurrentQueue_InsertOnly() *ConcurrentQueue_InsertOnly

func (*ConcurrentQueue_InsertOnly) Add Uses

func (self *ConcurrentQueue_InsertOnly) Add(value uint)

func (*ConcurrentQueue_InsertOnly) Slice Uses

func (self *ConcurrentQueue_InsertOnly) Slice() []uint

type DBSCANClusterer Uses

type DBSCANClusterer struct {
    MinPts, SortDimensionIndex int
    AutoSelectDimension        bool
    // contains filtered or unexported fields
}

func NewDBSCANClusterer Uses

func NewDBSCANClusterer(eps float64, minPts int) *DBSCANClusterer

func (*DBSCANClusterer) BuildNeighborhoodMap Uses

func (this *DBSCANClusterer) BuildNeighborhoodMap(data []ClusterablePoint) []*ConcurrentQueue_InsertOnly

func (*DBSCANClusterer) CalcDistance Uses

func (this *DBSCANClusterer) CalcDistance(aPoint, bPoint []float64) float64

func (*DBSCANClusterer) Cluster Uses

func (this *DBSCANClusterer) Cluster(data []ClusterablePoint) [][]ClusterablePoint

* step 1: sort data by a dimension step 2: slide through sorted data (in parallel), and compute all points in range of eps (everything above eps is definitely isn't directly reachable) step 3: build neighborhood map & proceed DFS *

func (*DBSCANClusterer) GetEps Uses

func (this *DBSCANClusterer) GetEps() float64

func (*DBSCANClusterer) PredictDimensionByMaxVariance Uses

func (this *DBSCANClusterer) PredictDimensionByMaxVariance(data []ClusterablePoint) int

*

* Calculate variance for each dimension (in parallel), returns dimension index with max variance

func (*DBSCANClusterer) SetEps Uses

func (this *DBSCANClusterer) SetEps(eps float64)

type NamedPoint Uses

type NamedPoint struct {
    Name  string
    Point []float64
}

func NewNamedPoint Uses

func NewNamedPoint(name string, point []float64) *NamedPoint

func (*NamedPoint) Copy Uses

func (self *NamedPoint) Copy() *NamedPoint

func (*NamedPoint) GetPoint Uses

func (self *NamedPoint) GetPoint() []float64

func (*NamedPoint) String Uses

func (self *NamedPoint) String() string

Package dbscan imports 6 packages (graph). Updated 2019-04-23. Refresh now. Tools for package owners.