14 #ifndef __MLPACK_METHODS_KMEANS_SAMPLE_INITIALIZATION_HPP 15 #define __MLPACK_METHODS_KMEANS_SAMPLE_INITIALIZATION_HPP 37 template<
typename MatType>
39 const size_t clusters,
42 centroids.set_size(data.n_rows, clusters);
43 for (
size_t i = 0; i < clusters; ++i)
47 centroids.col(i) = data.col(index);
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.
SampleInitialization()
Empty constructor, required by the InitialPartitionPolicy type definition.
Definition: sample_initialization.hpp:27
Definition: sample_initialization.hpp:23
Miscellaneous math random-related routines.
int RandInt(const int hiExclusive)
Generates a uniform random integer.
Definition: random.hpp:110
static void Cluster(const MatType &data, const size_t clusters, arma::mat ¢roids)
Initialize the centroids matrix by randomly sampling points from the data matrix. ...
Definition: sample_initialization.hpp:38