Skip to content

Commit 798b936

Browse files
committed
Implemented PRESS calculation
1 parent 74adf7a commit 798b936

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Scripts/Data_analysis.mlx

42.3 KB
Binary file not shown.

Scripts/PLS.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
P {mustBeNumeric}
2020
X_hat {mustBeNumeric}
2121
Y_hat {mustBeNumeric}
22+
PRESS {mustBeNumeric}
2223
Y_hat_bin {mustBeNumeric}
2324
MCE {mustBeNumeric}
2425
confMatrix {mustBeNumeric}
@@ -90,16 +91,20 @@
9091
% estimation of X_hat and Y_hat
9192
obj.X_hat = obj.T*obj.P';
9293
if obj.normal
94+
obj.PRESS = PLS.computePRESS(obj.X_norm, obj.X_hat);
9395
obj.Y_hat = obj.X_norm*obj.B;
9496
if PCA.PCA == "true"
9597
[obj.PCA.P, obj.PCA.T] = pca(obj.X_norm, "NumComponents", obj.alpha);
9698
obj.PCA.X_hat = obj.PCA.T*obj.PCA.P';
99+
obj.PCA.PRESS = PLS.computePRESS(obj.X_norm, obj.PCA.X_hat);
97100
end
98101
else
102+
obj.PRESS = PLS.computePRESS(obj.X, obj.X_hat);
99103
obj.Y_hat = obj.X*obj.B;
100104
if PCA.PCA == "true"
101105
[obj.PCA.P, obj.PCA.T] = pca(obj.X, 'NumComponents', obj.alpha);
102106
obj.PCA.X_hat = obj.PCA.T*obj.PCA.P';
107+
obj.PCA.PRESS = PLS.computePRESS(obj.X, obj.PCA.X_hat);
103108
end
104109
end
105110
end
@@ -119,7 +124,6 @@
119124
else
120125
Y_hat_new = X_new*obj.B;
121126
end
122-
Y_hat_new
123127
Y_hat_bin_new = PLS.classifyData(Y_hat_new);
124128
end
125129

@@ -398,6 +402,13 @@
398402
end
399403
end
400404
end
405+
406+
methods (Static)
407+
function PRESS = computePRESS(X, X_hat)
408+
[nX, mX] = size(X);
409+
PRESS = norm(X-X_hat, 'fro')/(nX*mX);
410+
end
411+
end
401412

402413
methods (Static, Access = private)
403414
function Y_hat_bin = classifyData(Y_hat)

0 commit comments

Comments
 (0)