Skip to contents

check_enough_train_data creates a specification of a recipe operation that will check if variables contain enough data.

Usage

check_enough_train_data(
  recipe,
  ...,
  n = NULL,
  epi_keys = NULL,
  drop_na = TRUE,
  role = NA,
  trained = FALSE,
  columns = NULL,
  skip = TRUE,
  id = rand_id("enough_train_data")
)

Arguments

recipe

A recipe object. The check will be added to the sequence of operations for this recipe.

...

One or more selector functions to choose variables for this check. See selections() for more details. You will usually want to use recipes::all_predictors() here.

n

The minimum number of data points required for training. If this is NULL, the total number of predictors will be used.

epi_keys

A character vector of column names on which to group the data and check threshold within each group. Useful if your forecaster trains per group (for example, per geo_value).

drop_na

A logical for whether to count NA values as valid rows.

role

Not used by this check since no new variables are created.

trained

A logical for whether the selectors in ... have been resolved by prep().

columns

An internal argument that tracks which columns are evaluated for this check. Should not be used by the user.

skip

A logical. Should the check be skipped when the recipe is baked by bake()? While all operations are baked when prep() is run, some operations may not be able to be conducted on new data (e.g. processing the outcome variable(s)). Care should be taken when using skip = TRUE as it may affect the computations for subsequent operations.

id

A character string that is unique to this check to identify it.

Details

This check will break the bake function if any of the checked columns have not enough non-NA values. If the check passes, nothing is changed to the data.

tidy() results

When you tidy() this check, a tibble with column terms (the selectors or variables selected) is returned.