mlpack  1.0.12
random_partition.hpp
Go to the documentation of this file.
1 
15 #ifndef __MLPACK_METHODS_KMEANS_RANDOM_PARTITION_HPP
16 #define __MLPACK_METHODS_KMEANS_RANDOM_PARTITION_HPP
17 
18 #include <mlpack/core.hpp>
19 
20 namespace mlpack {
21 namespace kmeans {
22 
29 {
30  public:
33 
45  template<typename MatType>
46  inline static void Cluster(const MatType& data,
47  const size_t clusters,
48  arma::Col<size_t>& assignments)
49  {
50  // Implementation is so simple we'll put it here in the header file.
51  assignments = arma::shuffle(arma::linspace<arma::Col<size_t> >(0,
52  (clusters - 1), data.n_cols));
53  }
54 };
55 
56 };
57 };
58 
59 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: load.hpp:23
RandomPartition()
Empty constructor, required by the InitialPartitionPolicy policy.
static void Cluster(const MatType &data, const size_t clusters, arma::Col< size_t > &assignments)
Partition the given dataset into the given number of clusters.
A very simple partitioner which partitions the data randomly into the number of desired clusters...