mlpack
3.1.1
src
mlpack
methods
kmeans
random_partition.hpp
Go to the documentation of this file.
1
13
#ifndef MLPACK_METHODS_KMEANS_RANDOM_PARTITION_HPP
14
#define MLPACK_METHODS_KMEANS_RANDOM_PARTITION_HPP
15
16
#include <
mlpack/prereqs.hpp
>
17
18
namespace
mlpack
{
19
namespace
kmeans {
20
26
class
RandomPartition
27
{
28
public
:
30
RandomPartition
() { }
31
43
template
<
typename
MatType>
44
inline
static
void
Cluster
(
const
MatType& data,
45
const
size_t
clusters,
46
arma::Row<size_t>& assignments)
47
{
48
// Implementation is so simple we'll put it here in the header file.
49
assignments = arma::shuffle(arma::linspace<arma::Row<size_t>>(0,
50
(clusters - 1), data.n_cols));
51
}
52
54
template
<
typename
Archive>
55
void
serialize
(Archive&
/* ar */
,
const
unsigned
int
/* version */
) { }
56
};
57
58
}
// namespace kmeans
59
}
// namespace mlpack
60
61
#endif
prereqs.hpp
mlpack
@serialization.hpp
Definition:
add_to_po.hpp:21
mlpack::kmeans::RandomPartition::RandomPartition
RandomPartition()
Empty constructor, required by the InitialPartitionPolicy policy.
Definition:
random_partition.hpp:30
mlpack::kmeans::RandomPartition::serialize
void serialize(Archive &, const unsigned int)
Serialize the partitioner (nothing to do).
Definition:
random_partition.hpp:55
mlpack::kmeans::RandomPartition
A very simple partitioner which partitions the data randomly into the number of desired clusters.
Definition:
random_partition.hpp:26
mlpack::kmeans::RandomPartition::Cluster
static void Cluster(const MatType &data, const size_t clusters, arma::Row< size_t > &assignments)
Partition the given dataset into the given number of clusters.
Definition:
random_partition.hpp:44
Generated by
1.8.17