mirror of
https://github.com/muesli/kmeans.git
synced 2025-09-27 03:56:17 +08:00
Added Cluster.removePoint(point) for convenience
This commit is contained in:
12
cluster.go
12
cluster.go
@@ -26,6 +26,18 @@ func (c Clusters) Nearest(point Point) int {
|
|||||||
return ci
|
return ci
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// removePoint removes a point's assignment to this cluster
|
||||||
|
func (c *Cluster) removePoint(p Point) {
|
||||||
|
var pp Points
|
||||||
|
for _, v := range c.Points {
|
||||||
|
if !v.Equal(p) {
|
||||||
|
pp = append(pp, p)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Points = pp
|
||||||
|
}
|
||||||
|
|
||||||
// recenter recenters a cluster
|
// recenter recenters a cluster
|
||||||
func (c *Cluster) recenter() {
|
func (c *Cluster) recenter() {
|
||||||
center, err := c.Points.Mean()
|
center, err := c.Points.Mean()
|
||||||
|
Reference in New Issue
Block a user