Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
vulpes::geometry::KMeansBase< T, Dim > Class Template Referenceabstract

Base class template for KMeans clustering algorithms. More...

#include <kmeans.hpp>

Inheritance diagram for vulpes::geometry::KMeansBase< T, Dim >:
[legend]

Public Types

using LabelType = std::vector<size_t>
using CentersType = Eigen::Matrix<T, Dim, Eigen::Dynamic>
using DataType = Eigen::Map<const CentersType>

Public Member Functions

 KMeansBase (size_t k, size_t max_iter=1e6, T tol=1e-6, size_t seed=0)
 KMeansBase ()
virtual void fit ()=0
 Runs the KMeans clustering algorithm on the input data.
auto getIterNum () const
const LabelType & getLabels () const
const CentersType & getCentroids () const

Protected Attributes

bool m_fitted
size_t m_n_clusters
size_t m_max_iter
T m_tol
size_t m_seed
size_t m_n_samples
size_t m_n_iter
CentersType m_centroids
LabelType m_labels

Detailed Description

template<typename T, size_t Dim>
class vulpes::geometry::KMeansBase< T, Dim >

Base class template for KMeans clustering algorithms.

This class defines the shared interface and common attributes for all KMeans-based clustering algorithms, such as KMeansNaive. It provides type definitions, constructors, and accessors for cluster labels, centroids, and algorithm parameters. Derived classes should implement the clustering logic by overriding the pure virtual fit() method.

Template Parameters
TFloating point type for the input data (e.g., float, double).
DimDimensionality of the input data

Member Typedef Documentation

◆ CentersType

template<typename T, size_t Dim>
using vulpes::geometry::KMeansBase< T, Dim >::CentersType = Eigen::Matrix<T, Dim, Eigen::Dynamic>

◆ DataType

template<typename T, size_t Dim>
using vulpes::geometry::KMeansBase< T, Dim >::DataType = Eigen::Map<const CentersType>

◆ LabelType

template<typename T, size_t Dim>
using vulpes::geometry::KMeansBase< T, Dim >::LabelType = std::vector<size_t>

Constructor & Destructor Documentation

◆ KMeansBase() [1/2]

template<typename T, size_t Dim>
vulpes::geometry::KMeansBase< T, Dim >::KMeansBase ( size_t k,
size_t max_iter = 1e6,
T tol = 1e-6,
size_t seed = 0 )
inlineexplicit

◆ KMeansBase() [2/2]

template<typename T, size_t Dim>
vulpes::geometry::KMeansBase< T, Dim >::KMeansBase ( )
inline

Member Function Documentation

◆ fit()

template<typename T, size_t Dim>
virtual void vulpes::geometry::KMeansBase< T, Dim >::fit ( )
pure virtual

Runs the KMeans clustering algorithm on the input data.

This method must be implemented by derived classes. It performs clustering and updates the centroids and labels accordingly.

Implemented in vulpes::geometry::KMeansNaive< T, Dim >.

◆ getCentroids()

template<typename T, size_t Dim>
const CentersType & vulpes::geometry::KMeansBase< T, Dim >::getCentroids ( ) const
inline

◆ getIterNum()

template<typename T, size_t Dim>
auto vulpes::geometry::KMeansBase< T, Dim >::getIterNum ( ) const
inline

◆ getLabels()

template<typename T, size_t Dim>
const LabelType & vulpes::geometry::KMeansBase< T, Dim >::getLabels ( ) const
inline

Member Data Documentation

◆ m_centroids

template<typename T, size_t Dim>
CentersType vulpes::geometry::KMeansBase< T, Dim >::m_centroids
protected

◆ m_fitted

template<typename T, size_t Dim>
bool vulpes::geometry::KMeansBase< T, Dim >::m_fitted
protected

◆ m_labels

template<typename T, size_t Dim>
LabelType vulpes::geometry::KMeansBase< T, Dim >::m_labels
protected

◆ m_max_iter

template<typename T, size_t Dim>
size_t vulpes::geometry::KMeansBase< T, Dim >::m_max_iter
protected

◆ m_n_clusters

template<typename T, size_t Dim>
size_t vulpes::geometry::KMeansBase< T, Dim >::m_n_clusters
protected

◆ m_n_iter

template<typename T, size_t Dim>
size_t vulpes::geometry::KMeansBase< T, Dim >::m_n_iter
protected

◆ m_n_samples

template<typename T, size_t Dim>
size_t vulpes::geometry::KMeansBase< T, Dim >::m_n_samples
protected

◆ m_seed

template<typename T, size_t Dim>
size_t vulpes::geometry::KMeansBase< T, Dim >::m_seed
protected

◆ m_tol

template<typename T, size_t Dim>
T vulpes::geometry::KMeansBase< T, Dim >::m_tol
protected

The documentation for this class was generated from the following file: