Skip to content

Setting seed for kmeans #23

Description

@gucouture

Hi!

Is there any way to reproduce kmeans results by setting the seed? I don’t see how.

I tried every possible ways to manage with set.seed, arma seed, math::randomSeed, custom seed through refined start, and stuff. I finally found that without initialGuesses, the initials guesses are random. Thus, I went into the random_partition.hpp and changed

This line
assignments = arma::shuffle(arma::linspace<arma::Col<size_t> >(0, (clusters - 1), data.n_cols));

by those lines (this example is using a seed = 11) :
assignments = arma::linspace<arma::Col<size_t> >(0, (clusters - 1), data.n_cols); shuffle(assignments.begin(), assignments.end(), std::default_random_engine(11));

This is the only workaround I've found. It would be cool to enhance the module in order to reproduce results by setting easily a seed value.

Thank you!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions