Implements the kmeans++ algo to select the landmarks in the geometric method

Former-commit-id: 732404a0dc6d7276e4e479dd2481aa4bd42d4ce5
This commit is contained in:
2023-12-11 16:07:03 +01:00
parent 37c3e16d5d
commit 2caaa62485
8 changed files with 259 additions and 140 deletions

View File

@ -15,6 +15,12 @@ func (r intRanker) Len() int { return len(r.x) }
func (r intRanker) Less(i, j int) bool { return r.x[r.r[i]] < r.x[r.r[j]] }
func (r intRanker) Swap(i, j int) { r.r[i], r.r[j] = r.r[j], r.r[i] }
// IntOrder sorts a slice of integers and returns a slice
// of indices that represents the order of the sorted
// elements.
//
// `data` is a slice of integers to be ordered.
// Returns a slice of the ordered indices.
func IntOrder(data []int) []int {
if len(data) == 0 {
return nil