Skip to content

Commit

Permalink
#103: umap_transform dens_scale params are swapped
Browse files Browse the repository at this point in the history
  • Loading branch information
jlmelville committed Nov 3, 2022
1 parent 784a1c2 commit 391c884
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions R/transform.R
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ umap_transform <- function(X = NULL, model = NULL,

if (method == "leopold") {
dens_scale <- model$dens_scale
ai <- model$ai
aj <- model$ai
rad_coeff <- model$rad_coeff
}

Expand Down Expand Up @@ -630,12 +630,12 @@ umap_transform <- function(X = NULL, model = NULL,
method <- tolower(method)
if (method == "leopold") {
# Use the linear model 2 log ai = -m log(localr) + c
aj <- exp(0.5 * ((-log(localr) * rad_coeff[2]) + rad_coeff[1]))
ai <- exp(0.5 * ((-log(localr) * rad_coeff[2]) + rad_coeff[1]))
# Prevent too-small/large aj
min_aj <- min(sqrt(a * 10 ^ (-2 * dens_scale)), 0.1)
aj[aj < min_aj] <- min_aj
max_aj <- sqrt(a * 10 ^ (2 * dens_scale))
aj[aj > max_aj] <- max_aj
min_ai <- min(sqrt(a * 10 ^ (-2 * dens_scale)), 0.1)
ai[ai < min_ai] <- min_ai
max_ai <- sqrt(a * 10 ^ (2 * dens_scale))
ai[ai > max_ai] <- max_ai
method <- "leopold2"
}

Expand Down
2 changes: 1 addition & 1 deletion src/r_uwot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void create_umapai2(UmapFactory &umap_factory, List method_args) {
validate_args(method_args, arg_names);

std::vector<float> ai = method_args["ai"];
std::vector<float> aj = method_args["ai"];
std::vector<float> aj = method_args["aj"];
float b = method_args["b"];
std::size_t ndim = method_args["ndim"];
const uwot::umapai2_gradient gradient(ai, aj, b, ndim);
Expand Down

0 comments on commit 391c884

Please sign in to comment.