Ejemplo n.º 1
0
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.NewKMeans(this.rphashObject.GetK(), centroids, this.centroidCounter.GetCounts()).GetCentroids()
	}
	return this.centroids
}
Ejemplo n.º 2
0
func (this *Stream) GetCentroidsOfflineStep() []float64 {
	var centroids []float64
	var counts []int32
	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.NewKMeans(this.rphashObject.GetK(), centroids, counts).GetCentroids()
	count := int((utils.Max(counts) + utils.Min(counts)) / 2)
	counts = []int32{}
	for i := 0; i < this.rphashObject.GetK(); i++ {
		counts = append(counts, int32(count))
	}
	this.counts = counts
	return this.centroids
}
Ejemplo n.º 3
0
func (this *Simple) GetCentroids() [][]float64 {
	if this.centroids == nil {
		this.Run()
	}
	return defaults.NewKMeans(this.streamObject.GetK(), this.centroids).GetCentroids()
}