Export Clusters.Nearest

This commit is contained in:
Christian Muehlhaeuser
2018-05-27 18:34:08 +02:00
parent 3cd22c49ed
commit f6a37b65ea
2 changed files with 3 additions and 4 deletions

View File

@@ -33,8 +33,8 @@ func (c Clusters) reset() {
}
}
// nearestCluster returns the index of the cluster nearest to point
func (c Clusters) nearestCluster(point Point) int {
// Nearest returns the index of the cluster nearest to point
func (c Clusters) Nearest(point Point) int {
var dist float64
var ci int

View File

@@ -74,7 +74,7 @@ func (m Kmeans) Partition(dataset Points, k int) (Clusters, error) {
clusters.reset()
for p, point := range dataset {
ci := clusters.nearestCluster(point)
ci := clusters.Nearest(point)
clusters[ci].Points = append(clusters[ci].Points, point)
if points[p] != ci {
points[p] = ci
@@ -103,7 +103,6 @@ func (m Kmeans) Partition(dataset Points, k int) (Clusters, error) {
if m.debug {
draw(clusters, i)
}
if changes < int(float64(len(dataset))*m.deltaThreshold) {
// fmt.Println("Aborting:", changes, int(float64(len(dataset))*m.TerminationThreshold))
break