View source: R/discriminant_projector.R
predict.discriminant_projector | R Documentation |
This produces class predictions or posterior-like scores for new data. We first
project the data into the subspace defined by x$v
, then either:
LDA approach (method="lda"
), which uses a (simplified)
linear discriminant formula or distance to class means in the subspace
combined with prior probabilities.
Euclid approach (method="euclid"
), which uses plain
Euclidean distance to each class mean in the subspace.
We return either a type="class"
label or type="prob"
posterior-like
matrix.
## S3 method for class 'discriminant_projector'
predict(
object,
new_data,
method = c("lda", "euclid"),
type = c("class", "prob"),
colind = NULL,
...
)
object |
A |
new_data |
A numeric matrix (or vector) with the same # of columns as the original data (unless partial usage). Rows=observations, columns=features. |
method |
Either |
type |
|
colind |
(optional) if partial columns are used, specify which columns
map to the subspace. If |
... |
further arguments (not used or for future expansions). |
If type="class"
, a factor vector of length n (predicted classes).
If type="prob"
, an (n x #classes) numeric matrix of posterior-like values, with row names matching new_data
if available.
Predict method for a discriminant_projector
This produces class predictions or posterior-like scores for new data, based on:
LDA approach (method="lda"
), which uses a linear discriminant
formula with a pooled covariance matrix if x\$Sigma
is given, or
the identity matrix if Sigma=NULL
. If that covariance matrix is not
invertible, a pseudo-inverse is used and a warning is emitted.
Euclid approach (method="euclid"
), which uses plain
Euclidean distance to each class mean in the subspace.
We return either a type="class"
label or type="prob"
posterior-like
matrix.
If type="class"
, a factor vector of length n (predicted classes).
If type="prob"
, an (n x #classes) numeric matrix of posterior-like values.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.