Cpp ML Library  1.0.0
A library of Machine Learning Algorithmns seen from the Udemy course Machine Learning A to Z.
Classes | Public Types | Public Member Functions | List of all members
HierarchicalClustering Class Reference

Agglomerative Hierarchical Clustering for clustering tasks. More...

#include <HierarchicalClustering.hpp>

Public Types

enum class  Linkage { SINGLE , COMPLETE , AVERAGE }
 Linkage criteria for clustering.
 

Public Member Functions

 HierarchicalClustering (int n_clusters=2, Linkage linkage=Linkage::AVERAGE)
 Constructs a HierarchicalClustering instance. More...
 
 ~HierarchicalClustering ()
 Destructor for HierarchicalClustering.
 
void fit (const std::vector< std::vector< double >> &X)
 Fits the clustering algorithm to the data. More...
 
std::vector< int > predict () const
 Predicts the cluster labels for the data. More...
 
std::vector< std::vector< double > > get_cluster_centers () const
 Retrieves the cluster centers (centroids) after fitting. More...
 

Detailed Description

Agglomerative Hierarchical Clustering for clustering tasks.

Constructor & Destructor Documentation

◆ HierarchicalClustering()

HierarchicalClustering::HierarchicalClustering ( int  n_clusters = 2,
Linkage  linkage = Linkage::AVERAGE 
)

Constructs a HierarchicalClustering instance.

Parameters
n_clustersThe number of clusters to form.
linkageThe linkage criterion to use.

Member Function Documentation

◆ fit()

void HierarchicalClustering::fit ( const std::vector< std::vector< double >> &  X)

Fits the clustering algorithm to the data.

Parameters
XA vector of feature vectors (data points).

◆ get_cluster_centers()

std::vector< std::vector< double > > HierarchicalClustering::get_cluster_centers ( ) const

Retrieves the cluster centers (centroids) after fitting.

Returns
A vector of cluster centroids.

◆ predict()

std::vector< int > HierarchicalClustering::predict ( ) const

Predicts the cluster labels for the data.

Returns
A vector of cluster labels.

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