mlpack
3.4.2
mlpack-3.4.2
src
mlpack
methods
kmeans
naive_kmeans.hpp
Go to the documentation of this file.
1
15
#ifndef MLPACK_METHODS_KMEANS_NAIVE_KMEANS_HPP
16
#define MLPACK_METHODS_KMEANS_NAIVE_KMEANS_HPP
17
#include <
mlpack/prereqs.hpp
>
18
19
namespace
mlpack
{
20
namespace
kmeans {
21
31
template
<
typename
MetricType,
typename
MatType>
32
class
NaiveKMeans
33
{
34
public
:
41
NaiveKMeans
(
const
MatType& dataset, MetricType& metric);
42
53
double
Iterate
(
const
arma::mat& centroids,
54
arma::mat& newCentroids,
55
arma::Col<size_t>& counts);
56
57
size_t
DistanceCalculations
()
const
{
return
distanceCalculations; }
58
59
private
:
61
const
MatType& dataset;
63
MetricType& metric;
64
66
size_t
distanceCalculations;
67
};
68
69
}
// namespace kmeans
70
}
// namespace mlpack
71
72
// Include implementation.
73
#include "naive_kmeans_impl.hpp"
74
75
#endif
prereqs.hpp
The core includes that mlpack expects; standard C++ includes and Armadillo.
mlpack
Linear algebra utility functions, generally performed on matrices or vectors.
Definition:
add_to_cli11.hpp:21
mlpack::kmeans::NaiveKMeans::DistanceCalculations
size_t DistanceCalculations() const
Definition:
naive_kmeans.hpp:57
mlpack::kmeans::NaiveKMeans::Iterate
double Iterate(const arma::mat ¢roids, arma::mat &newCentroids, arma::Col< size_t > &counts)
Run a single iteration of the Lloyd algorithm, updating the given centroids into the newCentroids mat...
mlpack::kmeans::NaiveKMeans::NaiveKMeans
NaiveKMeans(const MatType &dataset, MetricType &metric)
Construct the NaiveKMeans object with the given dataset and metric.
mlpack::kmeans::NaiveKMeans
This is an implementation of a single iteration of Lloyd's algorithm for k-means.
Definition:
naive_kmeans.hpp:33
Generated by
1.8.20