transform.PCA.Rd
Similar to other transform methods, this function transforms values from a "PCA" object.
# S3 method for PCA
transform(
model,
data,
key,
features = NULL,
n.components = NULL,
scaling = NULL,
thread.ratio = NULL,
...
)
PCA R6 model
The model you want to transform
DataFrame
DataFrame containting the data.
character
Name of the ID column.
character of list of characters, optional
Name of feature columns for prediction.
If not provided, it defaults to all non-key columns of data.
integer, optional
Number of components to be retained.
The value range is from 1 to number of features.
Defaults to number of features.
logical, optional
If TRUE, scale variables to have unit variance before the analysis takes place.
Defaults to FALSE.
Reserved parameter.
DataFrame
Transformed variable values corresponding to each data point,
structured as follows:
ID column, with same name and type as data's ID column.
Score columns, type DOUBLE, representing the component score values of each data point.
Perform the transformation on DataFrame data2 using "PCA" object pca:
> data2$Collect()
ID X1 X2 X3 X4 X5 X6
1 1 2 32 10 54 38 20
2 2 9 57 20 25 48 19
3 3 12 24 28 35 30 20
4 4 15 42 27 36 61 27
Call the function:
> result <- transform(pca, data2, key="ID", n.components=4, scaling = TRUE)
Output:
> result[[1]]$Collect()
ID COMPONENT_1 COMPONENT_2 COMPONENT_3 COMPONENT_4 COMPONENT_5 COMPONENT_6
1 1 -6.60374153 -12.352444 2.7068428 5.0252348 NA NA
2 2 -4.06006881 1.910325 -0.9619991 -1.2077427 NA NA
3 3 -6.33107883 -11.018845 12.5079870 2.3591360 NA NA
4 4 -0.03122317 -4.423641 6.3617901 -0.5825786 NA NA