Learn R Programming

ggmlR (version 0.8.1)

augment.ggmlr_parsnip_model: Augment new data with predictions from a fitted ggml parsnip model

Description

Adds prediction columns to `new_data`, broom style. For classification this appends `.pred_class` plus one `.pred_<level>` probability column per class; for regression it appends `.pred`. Predictions are produced by the existing `predict()` method for ggml parsnip models (no duplicate inference logic).

Usage

# S3 method for ggmlr_parsnip_model
augment(x, new_data, ...)

Value

`new_data` as a tibble with prediction columns appended.

Arguments

x

A fitted `ggmlr_parsnip_model` (the engine object inside a parsnip fit; e.g. from `extract_fit_engine()`).

new_data

A data frame of predictors (same columns used for fitting).

...

Unused; for generic compatibility.

Examples

Run this code
ggml_set_n_threads(1L)  # deterministic, single OpenMP pool
spec <- parsnip::mlp(hidden_units = 8L, epochs = 3L) |>
  parsnip::set_engine("ggml", backend = "cpu") |>
  parsnip::set_mode("regression")
fit_obj <- parsnip::fit(spec, mpg ~ ., data = mtcars)
generics::augment(parsnip::extract_fit_engine(fit_obj), mtcars)

Run the code above in your browser using DataLab