1#ifndef UMAPPP_INITIALIZE_HPP
2#define UMAPPP_INITIALIZE_HPP
5#include "combine_neighbor_sets.hpp"
7#include "neighbor_similarities.hpp"
8#include "spectral_init.hpp"
28inline int choose_num_epochs(
int num_epochs,
size_t size) {
38 constexpr int limit = 10000, minimal = 200, maximal = 300;
40 num_epochs = minimal + maximal;
42 num_epochs = minimal +
static_cast<int>(std::ceil(maximal * limit /
static_cast<double>(size)));
72template<
typename Index_,
typename Float_>
74 internal::NeighborSimilaritiesOptions<Float_> nsopt;
78 internal::neighbor_similarities(x, nsopt);
80 internal::combine_neighbor_sets(x,
static_cast<Float_
>(options.
mix_ratio));
83 if (options.
initialize == InitializeMethod::SPECTRAL || options.
initialize == InitializeMethod::SPECTRAL_ONLY) {
84 bool attempt = internal::spectral_init(x, num_dim, embedding, options.
num_threads);
85 if (!attempt && options.
initialize == InitializeMethod::SPECTRAL) {
86 internal::random_init(x.size(), num_dim, embedding);
88 }
else if (options.
initialize == InitializeMethod::RANDOM) {
89 internal::random_init(x.size(), num_dim, embedding);
93 if (options.
a <= 0 || options.
b <= 0) {
95 options.
a = found.first;
96 options.
b = found.second;
126template<
typename Dim_,
typename Index_,
typename Float_>
153template<
typename Dim_,
typename Index_,
typename Float_>
Defines the NeighborList alias.
Status of the UMAP algorithm.
Status of the UMAP optimization iterations.
Definition Status.hpp:25
int num_epochs() const
Definition Status.hpp:106
NeighborList< Index_, Float_ > find_nearest_neighbors(const Prebuilt< Dim_, Index_, Float_ > &index, int k, int num_threads=1)
Methods for UMAP.
Definition initialize.hpp:21
knncolle::NeighborList< Index_, Float_ > NeighborList
Lists of neighbors for each observation.
Definition NeighborList.hpp:29
Status< Index_, Float_ > initialize(NeighborList< Index_, Float_ > x, int num_dim, Float_ *embedding, Options options)
Definition initialize.hpp:73
Options for initialize().
Definition Options.hpp:28
double mix_ratio
Definition Options.hpp:48
double bandwidth
Definition Options.hpp:40
double min_dist
Definition Options.hpp:60
InitializeMethod initialize
Definition Options.hpp:88
double b
Definition Options.hpp:76
double a
Definition Options.hpp:68
int num_epochs
Definition Options.hpp:100
double spread
Definition Options.hpp:53
int num_threads
Definition Options.hpp:134
double local_connectivity
Definition Options.hpp:34