Skip to contents

S3 predict method for dsprrr Modules, providing a tidymodels-familiar interface. This is an alternative to run_dataset() that matches the pattern used by parsnip and other tidymodels packages.

Usage

# S3 method for class 'Module'
predict(object, new_data, ...)

# S3 method for class 'PredictModule'
predict(object, new_data, ...)

Arguments

object

A dsprrr Module object

new_data

A data frame or tibble with columns matching the module's signature inputs

...

Additional arguments passed to run_dataset()

Value

A tibble with the input columns plus prediction results. The output column is named according to the signature's output field.

Examples

if (FALSE) { # \dontrun{
# Create a module
mod <- signature("text -> sentiment") |>
  module(type = "predict", chat = chat_openai())

# Use predict() like parsnip models
new_data <- tibble::tibble(text = c("Great!", "Terrible"))
predict(mod, new_data)

# Equivalent to run_dataset()
run_dataset(mod, new_data, .llm = mod$chat)
} # }