GithubHelp home page GithubHelp logo

twolodzko / kernelboot Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 2.96 MB

Smoothed bootstrap and functions for sampling from kernel densities

R 83.42% C++ 14.07% C 1.22% Just 1.29%
r density kernel-density bootstrap random-generation simulation

kernelboot's Introduction

Ace of all trades living somewhere at the intersection of software engineering, machine learning, and product management.

kernelboot's People

Contributors

pbiecek avatar twolodzko avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

pbiecek

kernelboot's Issues

future_lapply(): Please use future_lapply() of the future.apply package

Hi, future 1.7.0 is now on CRAN and I'm now starting the process of deprecating the usage future::future_lapply(), which has moved to the future.apply package. Please upgrade your code to use:

importFrom(future.apply, future_lapply)

or

future.apply::future_lapply()

This should be a straightforward update without any surprises.

In the next release of the future package, future::future_lapply() will produce a formal "deprecated" warning and in the release after that it will produce a "defunct" error.

ignore parameter doesn't work

I am having issues getting kernelboot to work with data frames containing factor variables. This is true even when the model formula being fit only uses numeric variables.

Here is a simple reproducible example, trying both the default bw.silv and trying bw.nrd0

f <- function(dat){coef(lm(Sepal.Width ~ . , data = dat))}
kernelboot(iris, f, ignore = "Species")
**Error in bw.silv(data) : all columns need to be numeric**

kernelboot(iris, f, ignore = "Species", bw = "nrd0")
**Error in is.data.frame(x) : (list) object cannot be coerced to type 'double'**

The same occurs when omitting the factor variable from the model formula.

f <- function(dat){coef(lm(Sepal.Width ~ . -Species, data = dat))}
kernelboot(iris, f, ignore = "Species")
**Error in bw.silv(data) : all columns need to be numeric**

kernelboot(iris, f, ignore = "Species", bw = "nrd0")
**Error in is.data.frame(x) : (list) object cannot be coerced to type 'double'**

clang-UBSAN warning on CRAN

clang-UBSAN raises the following warning:

R Under development (unstable) (2018-06-28 r74935) -- "Unsuffered Consequences"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(testthat)
> library(kernelboot)
> 
> test_check("kernelboot")
/data/gannet/ripley/R/test-clang/Rcpp/include/Rcpp/sugar/operators/Comparator_With_One_Value.h:59:10: runtime error: nan is outside the range of representable values of type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /data/gannet/ripley/R/test-clang/Rcpp/include/Rcpp/sugar/operators/Comparator_With_One_Value.h:59:10 in 
══ testthat results  ═══════════════════════════════════════════════════════════
OK: 345 SKIPPED: 3 FAILED: 0
> 
> proc.time()
   user  system elapsed 
 18.506   0.523  20.211 

I wasn't able to reproduce it yet.

BUG: Error in kernelboot( ... : object '.Random.seed' not found

Hi, your kernelboot::kernelboot() assumes that .Random.seed exists (see below) but that is not always guaranteed to be the case.

> kernelboot::kernelboot
function (data, statistic, R = 500L, bw = "default", kernel = c("multivariate", 
    "gaussian", "epanechnikov", "rectangular", "triangular", 
    "biweight", "cosine", "optcosine", "none"), weights = NULL, 
    adjust = 1, shrinked = TRUE, ignore = NULL, parallel = FALSE, 
    workers = availableCores()) 
{
    call <- match.call()
    kernel <- match.arg(kernel)
    seed <- .Random.seed   <======== HERE
    n <- NROW(data)
    m <- NCOL(data)
    vars <- NULL

I think the simplest solution is to use:

    seed <- get0(".Random.seed", envir = .GlobalEnv, ifnotfound = NULL)

The reason why you haven't run into problems with this yet is when loading future (<= 1.14.0) together with your package, a side-effect was that .Random.seed was (incorrectly) created. I've now cleaned this up, which means that with future (> 1.14.0) .Random.seed may not be set. When running reverse package dependency checks, R CMD check kernelboot_0.1.5.tar.gz now produces:

* checking tests ...
  Running ‘test_parallel.R’
 ERROR
Running the tests in 'tests/test_parallel.R' failed.
Last 13 lines of output:
  +   set.seed(0xBEEF)
  +   s1 <- kernelboot(mtcars, function(data) coef(lm(mpg ~ disp + hp + drat, data = data)),
  +                    R = 10, parallel = TRUE)
  + 
  +   set.seed(0xBEEF)
  +   s2 <- kernelboot(mtcars, function(data) coef(lm(mpg ~ disp + hp + drat, data = data)),
  +                    R = 10, parallel = TRUE)
  + 
  +   stopifnot( all.equal(s1, s2) )
  + 
  + }
  Error in kernelboot(mtcars, function(data) coef(lm(mpg ~ disp + hp + drat,  : 
    object '.Random.seed' not found
  Calls: stopifnot -> kernelboot
  Execution halted

NOTICE: plan(multiprocess) of future is deprecated

Hi.

This is a friendly reminder that plan(multiprocess) of the future package is deprecated since future 1.20.0 (2020-11-03). It will eventually become defunct and removed. The background for this can be found in HenrikBengtsson/future#420.

Your kernelboot package relies on multiprocess, cf. https://github.com/twolodzko/kernelboot/search?q=multiprocess.

Please migrate your code to the platform-independent plan(multisession) or the Linux/macOS-specific plan(multicore). If you want to emulate what multiprocess does, you can do something like:

  if (parallelly::supportsMulticore()) {
    oplan <- plan(multicore)
  } else {
    oplan <- plan(multisession)
  }
  on.exit(plan(oplan))

BTW, if you don't already do so, please make sure to undo any plan() you set in your code, as illustrated by the above example. This is needed to guarantee that calling your code won't override settings that the user has set previously. You can read about this in https://future.futureverse.org/reference/plan.html#for-package-developers.

Thank you,

Henrik
(maintainer of the future package)

Your package breaks when defunct future::multiprocess will be removed

FYI, future::multiprocess has been deprecated since October 2020, and defunct since March 2023. It will soon be removed from future. When that happens, your package will break (see below). Could you please fix this? It's probably not used by your package anyway, since it's already defunct. Thank you.

  • checking Rd cross-references ... WARNING
    Missing link or links in documentation object 'jst_import.Rd':
      ‘[future:multiprocess]{future::multiprocess()}’
    
    See section 'Cross-references' in the 'Writing R Extensions' manual.
    

TESTS: Wrong assertion when availableCores() == 1

Hi, while running revdep checks on globals packages in single-core mode, I got:

 ERROR
Running the tests intests/test_parallel.Rfailed.
Complete output:
  > 
  > library("kernelboot")
  > 
  > # simply check if it fails
  > 
  > stopifnot( kernelboot(mtcars, function(data) coef(lm(mpg ~ disp + hp + drat, data = data)),
  +                       R = 10, parallel = TRUE)$param$parallel )
  Error: kernelboot(mtcars, function(data) coef(lm(mpg ~ disp + hp + drat,  .... is not TRUE
  Execution halted

This is because tests/test_parallel.R:

stopifnot( kernelboot(mtcars, function(data) coef(lm(mpg ~ disp + hp + drat, data = data)),
R = 10, parallel = TRUE)$param$parallel )

assumes that availableCores() > 1. See also https://github.com/twolodzko/kernelboot/blob/master/R/kernelboot.R#L355-L368

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.