Learn R Programming

hardhat (version 1.3.1)

run-forge: forge() according to a blueprint

Description

This is a developer facing function that is only used if you are creating your own blueprint subclass. It is called from forge() and dispatches off the S3 class of the blueprint. This gives you an opportunity to forge the new data in a way that is specific to your blueprint.

run_forge() is always called from forge() with the same arguments, unlike run_mold(), because there aren't different interfaces for calling forge(). run_forge() is always called as:

run_forge(blueprint, new_data = new_data, outcomes = outcomes)

If you write a blueprint subclass for new_xy_blueprint(), new_recipe_blueprint(), new_formula_blueprint(), or new_blueprint(), then your run_forge() method signature must match this.

Usage

run_forge(blueprint, new_data, ..., outcomes = FALSE)

# S3 method for default_formula_blueprint run_forge(blueprint, new_data, ..., outcomes = FALSE)

# S3 method for default_recipe_blueprint run_forge(blueprint, new_data, ..., outcomes = FALSE)

# S3 method for default_xy_blueprint run_forge(blueprint, new_data, ..., outcomes = FALSE)

Value

run_forge() methods return the object that is then immediately returned from forge(). See the return value section of forge() to understand what the structure of the return value should look like.

Arguments

blueprint

A preprocessing blueprint.

new_data

A data frame or matrix of predictors to process. If outcomes = TRUE, this should also contain the outcomes to process.

...

Not used.

outcomes

A logical. Should the outcomes be processed and returned as well?

Examples

Run this code
bp <- default_xy_blueprint()

outcomes <- mtcars["mpg"]
predictors <- mtcars
predictors$mpg <- NULL

mold <- run_mold(bp, x = predictors, y = outcomes)

run_forge(mold$blueprint, new_data = predictors)

Run the code above in your browser using DataLab