step_pridit: recipes step: PRIDIT composite score

View source: R/step_pridit.R

step_priditR Documentation

recipes step: PRIDIT composite score

Description

Creates a recipes preprocessing step that fits a PRIDIT model on the training data and appends a single composite score column to any data set passed to bake(). This enables genuine out-of-sample scoring: the empirical CDFs used for ridit transformation and the PCA weights are estimated on the training fold only and then applied to the test fold without re-fitting.

Usage

step_pridit(
  recipe,
  ...,
  role = "predictor",
  trained = FALSE,
  score_name = "PRIDIT_score",
  sign_correction = TRUE,
  ecdfs = NULL,
  weights = NULL,
  max_eigval = NULL,
  col_norms = NULL,
  skip = FALSE,
  id = recipes::rand_id("pridit")
)

Arguments

recipe

A recipe object.

...

One or more selector expressions passed to recipes::selections() that identify the numeric indicator columns to include in the PRIDIT model.

role

For the new score column: passed to add_role(). Default "predictor".

trained

Logical. Set automatically by prep(); do not change.

score_name

Character. Name of the new score column. Default "PRIDIT_score".

sign_correction

Logical. Passed to pridit. Default TRUE.

ecdfs

Internal. Stored empirical CDFs from training.

weights

Internal. Stored PRIDIT weight vector from training.

max_eigval

Internal. Stored largest eigenvalue from training.

col_norms

Internal. Stored column norms from training.

skip

Logical. If TRUE, skip this step during bake(new_data = NULL). Default FALSE.

id

Character. Unique step identifier.

Details

All selected columns must be numeric. The step does not remove the original columns; use step_rm() afterwards if a clean feature set is required.

Value

An updated recipe.

Examples

## Not run: 
library(recipes)

dat <- data.frame(
  id = letters[1:50],
  x1 = runif(50), x2 = runif(50), x3 = runif(50)
)

rec <- recipe(~ ., data = dat) |>
  update_role(id, new_role = "id") |>
  step_pridit(x1, x2, x3)

prepped <- prep(rec, training = dat)
bake(prepped, new_data = dat)

## End(Not run)


pridit documentation built on May 31, 2026, 5:07 p.m.