Template Class kmeans
Defined in File kmeans.hpp
Inheritance Relationships
Base Type
public rcppsw::er::client< kmeans< T > >
(Template Class client)
Class Documentation
-
template<typename T>
class kmeans : public rcppsw::er::client<kmeans<T>> Wrapper class for performing kmeans clustering.
- Template Parameters:
T – The type of the data that is being clustered. It must support the following operations: +=, /=, = .
Public Types
Public Functions
-
inline kmeans(const std::vector<T> &data_in, std::unique_ptr<base_clustering_impl<T, policy::NC>> impl, size_t k, size_t max_iter)
- Parameters:
data_in – Vector of data to cluster.
impl – The method and policy for clustering.
k – The # of clusters.
max_iter – Maximum # of iterations to perform.
-
inline membership_type<policy::NC> run(const dist_calc_ftype &dist_func)
Perform clustering. First the clustering_impl::initialize() method is called. Then, the clustering algorithm is iterated until one of the following is true:
The maximum # of iterations has been reached.
cluster_impl::converged() returns
TRUE
(checked after each iteration).
- Returns:
A vector where the index corresponds to the index of the data point in the input data, and the value corresponds to the cluster to which the data point belongs.