Skip to contents

Executes the transformation pipeline on input data and retrieve the output. Applies each transformation step defined in the model steps file in sequence, modifying the data accordingly.

Usage

run_model_pipeline(mod, x, mode = "output")

Arguments

mod

A model object created by prepare_model_pipeline.

x

Either a file path (character) to a CSV file containing the input data, or a data frame. The data must contain all columns specified as predictors in the variables file.

mode

A character string specifying what data to return. Can be one of:

  • "output": Only return the final output of the model. These are the values of all variables calculated in the final step found in the model steps file.

  • "full": Return all predictor and derived columns, which includes the predictor columns from the input data (as listed in the variables file), all intermediate variables created by the pipeline steps, and the final output of the model. Note that input columns which are not listed as predictors in the variables file are not included.

Default is "output".

Value

A data frame containing the pipeline output (when `mode = "output"`) or all data including intermediate columns (when `mode = "full"`).

Errors

  • inaccessible_file: Raised if a step specification file does not exist or, if `mod$sandbox_path` is set, is not a descendant of that directory.

  • invalid_file_format: Raised if a step specification file cannot be parsed as a CSV.

  • missing_columns: Raised when a step specification file is missing required columns.

  • missing_data_columns: Raised when predictor variable columns listed in the variables file are absent from the input data.

  • empty_step_file_path: Raised when a row in the model steps file has an empty filePath.

  • empty_pipeline: Raised when the model steps file defines no transformation steps, so the pipeline would produce no output.

  • unknown_step: Raised when a step name in the model steps file is not a recognized transformation type.

  • invalid_mode: Raised when the mode argument is not one of "output" or "full".

  • error: Any other error occurred that is not classified in the above errors.

See also

prepare_model_pipeline to prepare the model object

Examples

if (FALSE) { # \dontrun{
# Prepare and run pipeline
mod <- prepare_model_pipeline("path/to/model-export.csv")
output <- run_model_pipeline(mod, x = "path/to/input-data.csv")
head(output)

# Run on data frame
input_data <- read.csv("path/to/data.csv")
mod <- run_model_pipeline(mod, x = input_data)
} # }