gdkrmr / dimRed

A Framework for Dimensionality Reduction in R
https://www.guido-kraemer.com/software/dimred/
GNU General Public License v3.0
73 stars 15 forks source link

Non-standard parameters not passed through for embed() #50

Closed robjhyndman closed 4 years ago

robjhyndman commented 4 years ago

The documentation for embed() suggests that additional parameters can be passed via ..., but they seem to be ignored:

library(dimRed)
#> Loading required package: DRR
#> Loading required package: kernlab
#> Loading required package: CVST
#> Loading required package: Matrix
#> 
#> Attaching package: 'dimRed'
#> The following object is masked from 'package:stats':
#> 
#>     embed
#> The following object is masked from 'package:base':
#> 
#>     as.data.frame

sr <- loadDataSet("Swiss Roll", n = 2000, sigma = 0.05)
test <- embed(sr, "Isomap", knn = 50, eps = 1, ndim = 2, get_geod = FALSE)
#> Warning in matchPars(methodObject, list(...)): Parameter matching: eps is not a
#> standard parameter, ignoring.
#> 2020-04-28 17:11:55: Isomap START
#> 2020-04-28 17:11:55: constructing knn graph
#> 2020-04-28 17:11:55: calculating geodesic distances
#> 2020-04-28 17:11:59: Classical Scaling

Created on 2020-04-28 by the reprex package (v0.3.0)

gdkrmr commented 4 years ago

The Isomap implementation in dimRed does not have an eps parameter. Does it say so somewhere in the documentation?

If you really want to use an epsilon parameter for Isomap and dimRed, you can use MDS, it will just be as slow as the vegan implementation:

library(dimRed)
library(vegan)
sr <- loadDataSet("Swiss Roll", n = 2000, sigma = 0.05)
embed(sr, "MDS", ndim = 2,  d = function(x) isomapdist(dist(x), epsilon = 5))
ffancheng commented 4 years ago

In the help page for embed function, the argument ... is explained as "internally passed as a list to the dimensionality reduction method as pars = list(...)", where the pars is then passed to the fun = function (data, pars, keep.org.data = TRUE) in your Isomap-class here.

In line 72 and 77, pars$eps is used because it is an argument for your makeKNNgraph() function. However, the embed function is ignoring this eps parameter. So your Isomap implementation in dimRed does have an eps parameter.

Does this make sense?