![]() |
SemiDiscreteOT 1.0
Semi-Discrete Optimal Transport Library
|
Namespaces | |
namespace | details |
Classes | |
class | clustering_parameters |
Functions | |
template<typename T , size_t N> | |
std::tuple< std::vector< std::array< T, N > >, std::vector< uint32_t > > | kmeans_lloyd (const std::vector< std::array< T, N > > &data, const clustering_parameters< T > ¶meters) |
template<typename T , size_t N> | |
std::tuple< std::vector< std::array< T, N > >, std::vector< uint32_t > > | kmeans_lloyd (const std::vector< std::array< T, N > > &data, uint32_t k, uint64_t max_iter=0, T min_delta=-1.0) |
template<typename T , size_t N> | |
std::tuple< std::vector< std::array< T, N > >, std::vector< uint32_t > > | kmeans_lloyd_parallel (const std::vector< std::array< T, N > > &data, const clustering_parameters< T > ¶meters) |
template<typename T , size_t N> | |
std::tuple< std::vector< std::array< T, N > >, std::vector< uint32_t > > | kmeans_lloyd_parallel (const std::vector< std::array< T, N > > &data, uint32_t k, uint64_t max_iter=0, T min_delta=-1.0) |
template<typename T , size_t N> | |
std::vector< T > | dist_to_center (const std::vector< std::array< T, N > > &points, const std::array< T, N > ¢er) |
template<typename T , size_t N> | |
T | sum_dist (const std::vector< std::array< T, N > > &points, const std::array< T, N > ¢er) |
template<typename T , size_t N> | |
std::vector< std::array< T, N > > | get_cluster (const std::vector< std::array< T, N > > &points, const std::vector< uint32_t > &labels, const uint32_t label) |
template<typename T , size_t N> | |
T | means_inertia (const std::vector< std::array< T, N > > &points, const std::tuple< std::vector< std::array< T, N > >, std::vector< uint32_t > > &means, uint32_t k) |
template<typename T , size_t N> | |
std::tuple< std::vector< std::array< T, N > >, std::vector< uint32_t > > | get_best_means (const std::vector< std::array< T, N > > &points, uint32_t k, uint32_t n_init=10) |
template<typename T , size_t N> | |
size_t | predict (const std::vector< std::array< T, N > > ¢roids, const std::array< T, N > &query) |
template<typename T , size_t N> | |
std::vector< std::array< T, N > > | load_csv (const std::string &path) |
std::tuple< std::vector< std::array< T, N > >, std::vector< uint32_t > > dkm::kmeans_lloyd | ( | const std::vector< std::array< T, N > > & | data, |
const clustering_parameters< T > & | parameters | ||
) |
std::tuple< std::vector< std::array< T, N > >, std::vector< uint32_t > > dkm::kmeans_lloyd | ( | const std::vector< std::array< T, N > > & | data, |
uint32_t | k, | ||
uint64_t | max_iter = 0 , |
||
T | min_delta = -1.0 |
||
) |
std::tuple< std::vector< std::array< T, N > >, std::vector< uint32_t > > dkm::kmeans_lloyd_parallel | ( | const std::vector< std::array< T, N > > & | data, |
const clustering_parameters< T > & | parameters | ||
) |
Definition at line 121 of file dkm_parallel.hpp.
std::tuple< std::vector< std::array< T, N > >, std::vector< uint32_t > > dkm::kmeans_lloyd_parallel | ( | const std::vector< std::array< T, N > > & | data, |
uint32_t | k, | ||
uint64_t | max_iter = 0 , |
||
T | min_delta = -1.0 |
||
) |
std::vector< T > dkm::dist_to_center | ( | const std::vector< std::array< T, N > > & | points, |
const std::array< T, N > & | center | ||
) |
Calculates the Euclidean distance from each point in the given sequence to given center and returns the results as a vector.
points | Point sequence. |
center | Center point with which the distance of each point is calculated. |
Definition at line 39 of file dkm_utils.hpp.
T dkm::sum_dist | ( | const std::vector< std::array< T, N > > & | points, |
const std::array< T, N > & | center | ||
) |
Calculates sum of distances from each point in points to given center point.
points | Point sequence. |
center | Center point with which the distance of each point is calculated. |
Definition at line 57 of file dkm_utils.hpp.
std::vector< std::array< T, N > > dkm::get_cluster | ( | const std::vector< std::array< T, N > > & | points, |
const std::vector< uint32_t > & | labels, | ||
const uint32_t | label | ||
) |
Return a point sequence whose elements all belong to the same cluster given by label.
points | Sequence that were passed to dkm::kmeans_lloyd |
labels | Sequence of labels that were obtained from dkm:kmeans_lloyd |
label | Label of the cluster to be obtained. |
Definition at line 74 of file dkm_utils.hpp.
T dkm::means_inertia | ( | const std::vector< std::array< T, N > > & | points, |
const std::tuple< std::vector< std::array< T, N > >, std::vector< uint32_t > > & | means, | ||
uint32_t | k | ||
) |
Calculates inertia of a given k-means cluster. Inertia is defined as sum of Euclidean distances of each point to its closest cluster center.
points | Sequence that were passed to dkm::kmeans_lloyd |
means | Result of dkm::kmeans_lloyd |
k | Number of clusters |
Definition at line 99 of file dkm_utils.hpp.
std::tuple< std::vector< std::array< T, N > >, std::vector< uint32_t > > dkm::get_best_means | ( | const std::vector< std::array< T, N > > & | points, |
uint32_t | k, | ||
uint32_t | n_init = 10 |
||
) |
Return the best clustering obtained from a given number of k-means calculations.
points | Sequence of points to be clustered. |
k | Number of clusters |
n_init | Number of times a k-means clustering will be calculated. |
Definition at line 126 of file dkm_utils.hpp.
size_t dkm::predict | ( | const std::vector< std::array< T, N > > & | centroids, |
const std::array< T, N > & | query | ||
) |
Return the index of the cluster that has the closest centroid to the query
centroids | List of cluster centroids |
query | Query to which the closest centroids is found |
Definition at line 150 of file dkm_utils.hpp.
std::vector< std::array< T, N > > dkm::load_csv | ( | const std::string & | path | ) |
Load a dataset from a CSV file where each row is a point with N values.
path | Location of file on disk to load data from. |
Definition at line 169 of file dkm_utils.hpp.