func (this *Stream) GetCentroids() [][]float64 { if this.centroids == nil { this.Run() var centroids [][]float64 for _, cent := range this.centroidCounter.GetTop() { centroids = append(centroids, cent.Centroid()) } this.centroids = defaults.NewKMeansStream(this.rphashObject.GetK(), centroids, this.centroidCounter.GetCounts()).GetCentroids() } return this.centroids }
func (this *Stream) GetCentroidsOfflineStep() [][]float64 { var centroids [][]float64 var counts []int64 for i := 0; i < len(this.centroidCounter.GetTop()); i++ { centroids = append(centroids, this.centroidCounter.GetTop()[i].Centroid()) counts = append(counts, this.centroidCounter.GetCounts()[i]) } this.centroids = defaults.NewKMeansStream(this.rphashObject.GetK(), centroids, counts).GetCentroids() count := int((utils.Max(counts) + utils.Min(counts)) / 2) counts = []int64{} for i := 0; i < this.rphashObject.GetK(); i++ { counts = append(counts, int64(count)) } this.counts = counts return this.centroids }