From ed0ff05bd29a5425aca30d731a986056d78e5f98 Mon Sep 17 00:00:00 2001 From: Gscorreia89 Date: Mon, 27 Nov 2017 13:27:25 +0000 Subject: [PATCH] np.square replacement --- pyChemometrics/ChemometricsPCA.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyChemometrics/ChemometricsPCA.py b/pyChemometrics/ChemometricsPCA.py index 1b07776..0433976 100644 --- a/pyChemometrics/ChemometricsPCA.py +++ b/pyChemometrics/ChemometricsPCA.py @@ -474,14 +474,14 @@ def cross_validation(self, x, cv_method=KFold(7, True), outputdist=False, press_ press_testset = 0 for column in range(0, x[xtest, :].shape[1]): xpred = cv_pipeline.scaler.transform(cv_pipeline._press_impute_pinv(x[xtest, :], column)) - press_testset += np.sum((xtest_scaled[:, column] - xpred[:, column]) ** 2) + press_testset += np.sum(np.square(xtest_scaled[:, column] - xpred[:, column])) cv_varexplained_test.append(1 - (press_testset / tss)) total_press += press_testset else: # RSS for row wise cross-validation pred_scores = cv_pipeline.transform(x[xtest, :]) pred_x = cv_pipeline.scaler.transform(cv_pipeline.inverse_transform(pred_scores)) - rss = np.sum((xtest_scaled - pred_x) ** 2) + rss = np.sum(np.square(xtest_scaled - pred_x)) total_press += rss cv_varexplained_test.append(1 - (rss / tss))