From c0179516a850bf7ae0e3177ec67cba0cc20b01d5 Mon Sep 17 00:00:00 2001 From: farid <farid.mohammadi@iws.uni-stuttgart.de> Date: Fri, 7 Jan 2022 12:26:40 +0100 Subject: [PATCH] [surrogate] scale parametersets before passing to the GP. --- BayesValidRox/surrogate_models/surrogate_models.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/BayesValidRox/surrogate_models/surrogate_models.py b/BayesValidRox/surrogate_models/surrogate_models.py index dbfee1347..a9d8391c0 100644 --- a/BayesValidRox/surrogate_models/surrogate_models.py +++ b/BayesValidRox/surrogate_models/surrogate_models.py @@ -784,7 +784,8 @@ class Metamodel: self.gp_poly = self.AutoVivification() self.pca = self.AutoVivification() self.LCerror = self.AutoVivification() - + self.x_scaler = {} + if self.ExpDesignFlag != 'sequential': # Read observations or MCReference if Model.MeasurementFile is not None or len(Model.Observations) != 0: @@ -839,8 +840,14 @@ class Metamodel: # Parallel fit regression if self.metaModel.lower() == 'gpe': + # Prepare the input matrix + scaler = MinMaxScaler() + X_S = scaler.fit_transform(CollocationPoints) + + self.x_scaler[key] = scaler + outDict = Parallel(n_jobs=-1, prefer='threads')( - delayed(self.GaussianProcessEmulator)(CollocationPoints,OutputMatrix[:,idx]) + delayed(self.GaussianProcessEmulator)(X_S,OutputMatrix[:,idx]) for idx in range(OutputMatrix.shape[1])) for idx in range(OutputMatrix.shape[1]): self.gp_poly[key]["y_"+str(idx+1)] = outDict[idx] @@ -1941,8 +1948,9 @@ class Metamodel: # Perdiction with GPE if self.metaModel.lower() == 'gpe': + X_T = self.x_scaler[Outkey].transform(samples) gp = self.gp_poly[Outkey][Inkey] - y_mean, y_std = gp.predict(samples, return_std=True) + y_mean, y_std = gp.predict(X_T, return_std=True) else: # Perdiction with PCE or pcekriging # Assemble Psi matrix -- GitLab