pcaTransform¶
Purpose¶
Reduces the dimension of a matrix using principal component vectors previously returned by pcaFit()
.
Format¶
Examples¶
new;
library gml;
// Get file name with full path
fname = getGAUSSHome() $+ "pkgs/gml/examples/winequality.csv";
// Load data
X = loadd(fname, ". -quality");
X_train = X[1:1000,.];
X_test = X[1001:rows(X),.];
n_components = 3;
struct pcaModel mdl;
mdl = pcaFit(X_train, n_components);
X_transform = pcaTransform(X_test, mdl);
After the above code, the first 5 rows of X_transform will be:
37.441282 1.2145282 -1.5416867
-2.0454164 -15.738950 1.0084994
21.315231 -2.4328631 0.15655108
41.776957 2.2901582 -2.2804431
0.73984770 -12.260074 -0.68265628
See also