Giter VIP home page Giter VIP logo

Comments (3)

mikemahoney218 avatar mikemahoney218 commented on August 10, 2024

This is a really funny bug -- the issue is that nested_cv() is checking to see if you're passing bootstraps() to outside, which will trigger a warning. To check that, it deparses the value of outside using deparse(), which returns a character vector, then uses grepl() to see if bootstraps is anywhere in the actual text of the arguments you passed.

The issue is that deparse() will break long calls into multiple elements, which causes the grepl() call to return a vector of multiple TRUE/FALSE values, which breaks the if() statement. So the triggering issue is that your argument to outside is too long. You can actually sneak around this by using partial argument matching, which gets the call to outside under the limit:

library(tidyverse)
library(rsample)
library(modeldata)

data(Chicago)
nested_cv(Chicago, 
          outside = sliding_period(i = date, 
                                   p = "month", 
                                   origin = Chicago$date[1]),
          inside = vfold_cv(v = 4)
)
#> # Nested resampling:
#> #  outer: Sliding period resampling
#> #  inner: 4-fold cross-validation
#> # A tibble: 187 × 3
#>    splits          id       inner_resamples
#>    <list>          <chr>    <list>         
#>  1 <split [10/28]> Slice001 <vfold [4 × 2]>
#>  2 <split [28/31]> Slice002 <vfold [4 × 2]>
#>  3 <split [31/30]> Slice003 <vfold [4 × 2]>
#>  4 <split [30/31]> Slice004 <vfold [4 × 2]>
#>  5 <split [31/30]> Slice005 <vfold [4 × 2]>
#>  6 <split [30/31]> Slice006 <vfold [4 × 2]>
#>  7 <split [31/31]> Slice007 <vfold [4 × 2]>
#>  8 <split [31/30]> Slice008 <vfold [4 × 2]>
#>  9 <split [30/31]> Slice009 <vfold [4 × 2]>
#> 10 <split [31/30]> Slice010 <vfold [4 × 2]>
#> # ℹ 177 more rows

Created on 2023-11-02 with reprex v2.0.2

To be clear, this is a bug and I opened #461 to fix it. I just think it's very funny that this bug winds up being "the argument to outside used too many characters". Who would have thought that was a thing that could happen?

Thanks for the excellent, excellent reprex -- made it so I could immediately see what was wrong, and I've stolen your example for #461 as a test to make sure this gets & stays fixed.

from rsample.

hfrick avatar hfrick commented on August 10, 2024

To echo Mike here: thanks a lot for the bug report with the excellent reprex! The fix is merged into the dev version 👍

from rsample.

github-actions avatar github-actions commented on August 10, 2024

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

from rsample.

Related Issues (20)

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.