xoopr / param6 Goto Github PK
View Code? Open in Web Editor NEWFast and lightweight R6 parameter interface
Home Page: https://xoopr.github.io/param6/
License: Other
Fast and lightweight R6 parameter interface
Home Page: https://xoopr.github.io/param6/
License: Other
Currently I have used these because I can't think of a good use-case when they may be required, but I'll re-add if this changes.
prm
to an already constructed ParameterSet
prm
to an already constructed ParameterSet
param6/R/ParameterSet_methods.R
Lines 22 to 32 in 690a8c9
Allow prefixes to be added to concatenate so that non-unique ids can be merged
As of 2022-08-26, param6's CRAN page says
Archived on 2022-08-20 at the maintainer's request.
Does this mean that {param6} is not maintained anymore or was there a different reason for this request?
Bottleneck is due to the cdf being calculated twice, despite pdf not changing. Add method to cache the transform, e.g.
$transform
for first time$.cached_params
$transform
in futureidentical($.cached_params[names(input_params)], input_params)
$.cached_params
@berndbischl @jakob-r @fkiraly
Many evenings and weekends later, I've finally got this package to a point where it will soon be ready for a 0.1.0 release (currently need further tests, CI, actions, etc.). As you may remember, we initially discussed this package in the context of various bottlenecks in distr6 and I said I would abstract the parameter interface to make use of set6 and Rcpp.
The results of this abstraction are promising. param6 is faster than paradox and distr6, in some cases over 200x faster. Once on CRAN and stable, I will finally be able to turn my attention back to my project with @eddelbuettel to fully integrate set6 with Rcpp or more generally R6 and Rcpp. This will only add to the speed and efficiency of param6.
The key differences of this package to other parameter interfaces are:
And others. Further details and a benchmark comparing distr6, paradox, and param6 are below.
Why am I pinging you now?
param6 clearly owes a debt to my previous work in distr6 as well as paradox. I will therefore be acknowledging these in the package README, I am also very happy to add you as contributors to the package (without any further contributions).
However, @berndbischl @jakob-r, given the results of the benchmarks and the fact that this offers almost all features of {paradox} with minimal (if any) API changes required, I would also like to invite you to formally collaborate on this package and consider its use in mlr3.
Below are some benchmarks comparing key features of param6, distr6, and
paradox.
param6 and paradox include separate parameter objects whereas distr6
does not, therefore these are separately compared and then together.
microbenchmark(
paradox = paradox::ParamDbl$new("a"),
param6 = param6::prm("a", "reals")
)
## Unit: microseconds
## expr min lq mean median uq max neval cld
## paradox 530.340 581.893 2856.005 685.5035 956.8250 188503.6 100 a
## param6 106.951 120.406 17325.349 146.1760 183.9735 1647753.6 100 a
First without values (this isn’t possible in distr6):
microbenchmark(
paradox = {
ParamSet$new(list(
ParamDbl$new("a")
))
},
distr6 = {
distr6::ParameterSet$new(
id = "a",
support = set6::Reals$new(),
value = 1
)
},
param6 = {
param6::ParameterSet$new(list(
prm("a", "reals")
))
}
)
## Unit: microseconds
## expr min lq mean median uq max neval cld
## paradox 1609.038 2174.3760 3513.4166 2781.0720 3747.9320 15659.522 100 b
## distr6 2472.554 3672.8845 6497.1024 5364.0035 7760.7680 49922.386 100 c
## param6 363.630 522.1065 909.8822 605.4135 836.1085 6982.207 100 a
With values:
microbenchmark(
paradox = {
ps <- ParamSet$new(list(
ParamDbl$new("a")
))
ps$values$a <- 1
},
distr6 = {
distr6::ParameterSet$new(
id = "a",
support = set6::Reals$new(),
value = 1
)
},
param6 = {
param6::ParameterSet$new(list(
prm("a", "reals", 1)
))
}
)
## Unit: microseconds
## expr min lq mean median uq max neval cld
## paradox 6105.521 7105.520 9939.8702 8267.198 10744.329 38730.537 100 c
## distr6 2248.061 2618.910 4086.1559 2935.913 3888.729 21699.133 100 b
## param6 454.811 544.949 888.8888 633.952 863.704 5595.308 100 a
paradox <- ParamSet$new(list(
ParamDbl$new("a")
))
paradox$values$a <- 1
param6 <- param6::ParameterSet$new(list(
prm("a", "reals", 1)
))
distr6 <- distr6::ParameterSet$new(
id = "a",
support = set6::Reals$new(),
value = 1
)
Getting values:
microbenchmark(
paradox = paradox$values$a,
distr6 = distr6$getParameterValue("a"),
param6 = param6$values$a
)
## Unit: microseconds
## expr min lq mean median uq max neval cld
## paradox 2.259 2.7495 5.81384 4.9830 7.493 22.859 100 a
## distr6 224.898 228.6225 313.32112 255.9815 300.272 1346.424 100 b
## param6 2.167 2.5280 4.80121 3.5695 5.660 25.868 100 a
And setting:
vals = list(a = 2)
microbenchmark(
paradox = {paradox$values = vals},
distr6 = distr6$setParameterValue(lst = vals),
param6 = {param6$values = vals}
)
## Unit: microseconds
## expr min lq mean median uq max neval cld
## paradox 4443.723 6170.4430 8538.9734 7403.095 9851.6190 24445.143 100 c
## distr6 1748.316 2178.0500 4642.6509 2783.577 3716.7730 89812.954 100 b
## param6 219.380 316.5885 628.3729 385.912 544.5435 6749.543 100 a
param6 removes the idea of a collection by instead embracing prefixes
and extraction methods.
paradox1 <- ParamSet$new(list(
ParamDbl$new("a")
))
paradox1$values$a <- 1
paradox2 <- ParamSet$new(list(
ParamDbl$new("b")
))
paradox2$values$b <- 2
param61 <- param6::ParameterSet$new(list(
prm("a", "reals", 1)
))
param62 <- param6::ParameterSet$new(list(
prm("b", "reals", 2)
))
distr61 <- distr6::ParameterSet$new(
id = "a",
support = set6::Reals$new(),
value = 1
)
distr62 <- distr6::ParameterSet$new(
id = "a",
support = set6::Reals$new(),
value = 2
)
microbenchmark(
paradox = ParamSetCollection$new(list(paradox1, paradox2)),
distr6 = ParameterSetCollection$new(D1 = distr61, D2 = distr62),
param6 = param6:::c.ParameterSet(param61, param62)
)
## Unit: microseconds
## expr min lq mean median uq max neval cld
## paradox 3434.875 4233.1565 7824.6972 5396.075 7550.0195 156833.891 100 b
## distr6 327.489 417.6195 651.8163 462.862 584.7045 4962.294 100 a
## param6 775.039 987.4275 1458.6529 1246.534 1584.7415 6533.939 100 a
Rep is a nice extra feature for replicating a parameter set with
identical properties. This isn’t currently possible in paradox or
distr6, benchmark below compare excluding full process and including.
paradox <- lapply(lapply(1:100, function(i) ParamDbl$new(paste0("Pre", i, "__a"))), function(.x) ParamSet$new(list(.x)))
distr6 <- rep(list(distr6::ParameterSet$new(
id = "a",
support = set6::Reals$new(),
value = 1
)), 100)
names(distr6) <- paste0("Pre__", 1:100)
microbenchmark(
paradox = ParamSetCollection$new(paradox),
distr6 = ParameterSetCollection$new(lst = distr6),
param6 = param6:::rep.ParameterSet(param6, 100, "Pre")
)
## Unit: microseconds
## expr min lq mean median uq max
## paradox 158895.858 200484.9905 300432.9309 234279.4435 328672.810 1695932.106
## distr6 449.279 548.6530 859.9568 661.9135 943.319 3711.874
## param6 684.358 807.7755 1415.5362 904.0350 1108.981 10954.299
## neval cld
## 100 b
## 100 a
## 100 a
microbenchmark(
paradox = {
paradox <- lapply(lapply(1:100, function(i)
ParamDbl$new(paste0("Pre", i, "__a"))), function(.x) ParamSet$new(list(.x)))
ParamSetCollection$new(paradox)
},
distr6 = {
distr6 <- rep(list(distr6::ParameterSet$new(
id = "a",
support = set6::Reals$new(),
value = 1
)), 100)
names(distr6) <- paste0("Pre__", 1:100)
ParameterSetCollection$new(lst = distr6)
},
param6 = {
param6 <- param6::ParameterSet$new(list(
prm("a", "reals", 1)))
param6:::rep.ParameterSet(param6, 100, "Pre")
}
)
## Unit: milliseconds
## expr min lq mean median uq max
## paradox 377.244803 522.665487 667.640479 586.522011 652.450550 2337.03302
## distr6 2.922534 3.710481 5.965636 4.785811 6.843199 22.44207
## param6 1.308180 1.528151 2.682907 1.974937 2.846436 11.05868
## neval cld
## 100 b
## 100 a
## 100 a
If param6 is used in both mlr packages and distr6 then one will have problems with backward compatibility as distr6 uses ParameterSet
but paradox uses ParamSet
. Given that heavier dependencies are in mlr and paradox is more user-facing than parameters in distr6, I will change to ParamSet
if used by mlr
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.