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"
28template<
typename Index_>
29int choose_num_epochs(
int num_epochs, Index_ size) {
39 constexpr Index_ limit = 10000;
40 const int minimal = 200, maximal = 300;
42 num_epochs = minimal + maximal;
44 num_epochs = minimal +
static_cast<int>(std::ceil(maximal *
static_cast<double>(limit) /
static_cast<double>(size)));
74template<
typename Index_,
typename Float_>
76 internal::NeighborSimilaritiesOptions<Float_> nsopt;
80 internal::neighbor_similarities(x, nsopt);
82 internal::combine_neighbor_sets(x,
static_cast<Float_
>(options.
mix_ratio));
85 if (options.
initialize == InitializeMethod::SPECTRAL || options.
initialize == InitializeMethod::SPECTRAL_ONLY) {
86 bool attempt = internal::spectral_init(x, num_dim, embedding, options.
num_threads);
87 if (!attempt && options.
initialize == InitializeMethod::SPECTRAL) {
88 internal::random_init<Index_>(x.size(), num_dim, embedding);
90 }
else if (options.
initialize == InitializeMethod::RANDOM) {
91 internal::random_init<Index_>(x.size(), num_dim, embedding);
95 if (options.
a <= 0 || options.
b <= 0) {
97 options.
a = found.first;
98 options.
b = found.second;
129template<
typename Index_,
typename Input_,
typename Float_>
132 return initialize(std::move(output), num_dim, embedding, std::move(options));
157template<
typename Index_,
typename Float_,
class Matrix_ = knncolle::Matrix<Index_, Float_> >
159 std::size_t data_dim,
168 return initialize(*prebuilt, num_dim, embedding, std::move(options));
Defines the NeighborList alias.
Status of the UMAP algorithm.
std::unique_ptr< Prebuilt< Index_, Data_, Distance_ > > build_unique(const Matrix_ &data) const
Status of the UMAP optimization iterations.
Definition Status.hpp:25
NeighborList< Index_, Distance_ > find_nearest_neighbors(const Prebuilt< Index_, Data_, Distance_ > &index, int k, int num_threads=1)
Methods for UMAP.
Definition initialize.hpp:21
Status< Index_, Float_ > initialize(NeighborList< Index_, Float_ > x, std::size_t num_dim, Float_ *embedding, Options options)
Definition initialize.hpp:75
knncolle::NeighborList< Index_, Float_ > NeighborList
Lists of neighbors for each observation.
Definition NeighborList.hpp:29
Options for initialize().
Definition Options.hpp:28
double mix_ratio
Definition Options.hpp:48
double negative_sample_rate
Definition Options.hpp:113
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
int num_neighbors
Definition Options.hpp:120
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