14 #ifndef __MLPACK_METHODS_KMEANS_SAMPLE_INITIALIZATION_HPP 15 #define __MLPACK_METHODS_KMEANS_SAMPLE_INITIALIZATION_HPP 37 template<
typename MatType>
38 inline static void Cluster(
const MatType& data,
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.
The core includes that mlpack expects; standard C++ includes and Armadillo.
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. ...
Miscellaneous math random-related routines.
int RandInt(const int hiExclusive)
Generates a uniform random integer.
SampleInitialization()
Empty constructor, required by the InitialPartitionPolicy type definition.