Пример #1
0
func NewSimpleArray(inData [][]float64, k int) *SimpleArray {
	randomSeed := rand.Int63()
	data := utils.NewIterator(inData)
	numDataPoints := len(inData)
	dimension := 2
	// As the number of rotations increases, the distance increases.
	// Increases the noise.
	numberOfRotations := 6
	numberOfSearches := 1
	numberOfProjections := 2
	numberOfBlurs := 2
	if data != nil {
		// Get the first vector in the data set's length.
		dimension = len(inData[0])
	}
	hashModulus := int64(math.MaxInt64)
	// Set the target dimension much lower.
	targetDimension := int(math.Floor(float64(dimension / 2)))
	decoder := decoder.NewSpherical(targetDimension, numberOfRotations, numberOfSearches)
	centroids := [][]float64{}
	topIDs := []int64{}
	return &SimpleArray{
		numDataPoints:       numDataPoints,
		data:                data,
		dimension:           dimension,
		numberOfProjections: numberOfProjections,
		randomSeed:          randomSeed,
		hashModulus:         hashModulus,
		k:                   k,
		numberOfBlurs:       numberOfBlurs,
		decoder:             decoder,
		centroids:           centroids,
		topIDs:              topIDs,
	}
}
Пример #2
0
func NewStreamObject(dimension, k int) *StreamObject {
	var centroids [][]float64
	var topIDs []int64
	numberOfRotations := 2
	numberOfSearches := 2
	targetDimension := 24
	decoder := decoder.NewSpherical(targetDimension, numberOfRotations, numberOfSearches)
	data := utils.NewIterator([][]float64{})
	return &StreamObject{
		decoder:             decoder,
		data:                data,
		dimension:           dimension,
		randomSeed:          int64(0),
		hashModulus:         int64(int(0 >> 1)),
		numberOfProjections: 1,
		numberOfBlurs:       1,
		k:                   k,
		topIDs:              topIDs,
		centroids:           centroids,
		numDataPoints:       0,
	}
}