score.apd_pca: Predict from a 'apd_pca'

View source: R/pca-score.R

score.apd_pcaR Documentation

Predict from a apd_pca

Description

Predict from a apd_pca

Usage

## S3 method for class 'apd_pca'
score(object, new_data, type = "numeric", ...)

Arguments

object

A apd_pca object.

new_data

A data frame or matrix of new samples.

type

A single character. The type of predictions to generate. Valid options are:

  • "numeric" for numeric predictions.

...

Not used, but required for extensibility.

Details

The function computes the principal components of the new data and their percentiles as compared to the training data. The number of principal components computed depends on the threshold given at fit time. It also computes the multivariate distance between each principal component and its mean.

Value

A tibble of predictions. The number of rows in the tibble is guaranteed to be the same as the number of rows in new_data.

Examples

train <- mtcars[1:20, ]
test <- mtcars[21:32, -1]

# Fit
mod <- apd_pca(mpg ~ cyl + log(drat), train)

# Predict, with preprocessing
score(mod, test)

applicable documentation built on Aug. 21, 2022, 1:06 a.m.