Learning how to use drake with tidymodels.
Something about using rsample's initial_time_split(), rather than just initial_split(), is giving me an error, when I run make(plan). I get the following:
#> > target data
#> > target split_data
#> Error in UseMethod("complement"): no applicable method for 'complement' applied to an object of class "rsplit"
Have really been racking my brain on this one. The function works fine, independently (ie. the following works):
I feel like I am missing something pretty basic.
Here is the full drake process in a single file (so that it is easier to post up on stack overflow).
Thanks in advance for the hints, as to what I'm doing wrong.
library(drake)
library(tidyverse)
library(tidymodels)
###################################################################
generate_data <- function() {
tibble(x = rnorm(1e5), y = rnorm(1e5))
}
split_the_data <- function(data) {
data %>%
initial_time_split()
}
fit_model <- function(data) {
summary(lm(y ~ x, data = data))
}
###################################################################
plan <- drake_plan(
data = generate_data(),
split_data = split_the_data(data),
model = fit_model(training(split_data))
)
###################################################################
make(plan)
This should now be fixed in the current development version (as of 93d60ef41119defc0432cc95d2dd6787e4a00b14). You can install it with
The error happened because
drake
callsNROW()
on every target (for dynamic branching purposes) and apparentlyNROW()
errors onrsplit
objects.Created on 2020-07-23 by the reprex package (v0.3.0)
Issue tracked in https://github.com/ropensci/drake/issues/1300.