Similar to other transform methods, this function transforms values from a fitted "DiscriminantAnalysis" object.

# S3 method for DiscriminantAnalysis
transform(model, data, key, features = NULL, proj.dim = NULL)

Format

S3 methods

Arguments

model

R6Class object
A 'DiscriminantAnalysis' object for projection.

data

DataFrame
DataFrame containting the data.

key

character
Name of the ID column.

features

character of list of characters, optional
Name of feature columns for prediction.
If not provided, it defaults to all non-key columns of data.

proj.dim

integer, optional
Dimension of the projected space, equivalent to the number of discriminant used for projection.
Defaults to the number of obtained discriminants.

Value

DataFrame
Projected result, structured as follows:

  • 1st column, ID, with the same name and data type as data for projection.

  • other columns with name DISCRIMINANT_i, where i iterates from 1 to the number of elements in features, data type DOUBLE.

Examples

Perform transform with a "DiscriminantAnalysis" object "lda":


 > result <- transform(lda,
                       test.set,
                       key = "ID"
                       features=list("ID","X1","X2","X3","X4"))
 

Output:


 > result$Collect()
     ID  DISCRIMINANT_1  DISCRIMINANT_2  DISCRIMINANT_3 DISCRIMINANT_4
 1    1       12.313584       -0.245578              NA             NA
 2    2       10.732231        1.432811              NA             NA
 3    3       11.215154        0.184080              NA             NA
 4    4       10.015174       -0.214504              NA             NA
 ...
 27  27       -7.058927       -0.877426              NA             NA
 28  28       -8.754272       -0.095103              NA             NA
 29  29       -8.935789        1.285655              NA             NA
 30  30       -8.674729       -1.208049              NA             NA