Abort processing when iterationThreshold has been reached

This commit is contained in:
Christian Muehlhaeuser
2018-05-29 03:54:00 +02:00
parent f93f9c935e
commit a032677f99

View File

@@ -107,7 +107,8 @@ func (m Kmeans) Partition(dataset Points, k int) (Clusters, error) {
if m.plotter != nil {
m.plotter.Plot(clusters, i)
}
if changes < int(float64(len(dataset))*m.deltaThreshold) {
if i == m.iterationThreshold ||
changes < int(float64(len(dataset))*m.deltaThreshold) {
// fmt.Println("Aborting:", changes, int(float64(len(dataset))*m.TerminationThreshold))
break
}