Skip to content

Commit

Permalink
PQ seed is now also used for KMeansClustering.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralph Gasser committed Aug 14, 2024
1 parent 1c75f83 commit bc4d0aa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ import java.io.ByteArrayInputStream
/**
* Configuration class for [PQIndex].
*
* @author Gabriel Zihlmann & Ralph Gasser
* @author Gabriel Zihlmann
* @author Ralph Gasser
* @version 1.3.0
*/
data class PQIndexConfig(val distance: Name.FunctionName, val numCentroids: Int, val subspaces: Int, val seed: Int = System.currentTimeMillis().toInt()) : IndexConfig<PQIndex> {

companion object {


/** The maximum number of subspaces. We cap this at 32 to limit the code length. */
private const val MAXIMUM_NUMBER_OF_SUBSPACES = 32

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ data class MultiStageQuantizer(val coarse: PQCodebook, val fine: Array<PQCodeboo

/* Prepare k-means clusterer. */
val reshape = distance.copy(dimensionsPerSubspace)
val random = SplittableRandom(System.currentTimeMillis())
val random = SplittableRandom(config.seed.toLong())
val coarseClusterer = KMeansClusterer(config.numCoarseCentroids, distance.type, random)
val fineClusterer = KMeansClusterer(config.numCentroids, distance.type, random)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ data class SingleStageQuantizer constructor(val codebooks: Array<PQCodebook>) {

/* Prepare k-means clusterer. */
val reshape = distance.copy(dimensionsPerSubspace)
val random = SplittableRandom(System.currentTimeMillis())
val random = SplittableRandom(config.seed.toLong())
val clusterer = KMeansClusterer(config.numCentroids, reshape.type, random)

/* Prepare codebooks. */
Expand Down

0 comments on commit bc4d0aa

Please sign in to comment.