From 579fe26f2db7925d8fcf37e34f84b7b897a41d78 Mon Sep 17 00:00:00 2001 From: faridm69 <faridmohammadi69@gmail.com> Date: Sat, 18 Jul 2020 10:09:01 +0200 Subject: [PATCH] [surroaget][FastARD] minor changes --- BayesValidRox/BayesInference/MCMC.py | 1 + BayesValidRox/surrogate_models/RegressionFastARD.py | 9 +++++---- BayesValidRox/surrogate_models/surrogate_models.py | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/BayesValidRox/BayesInference/MCMC.py b/BayesValidRox/BayesInference/MCMC.py index ae6bb7ba6..74a6190c8 100755 --- a/BayesValidRox/BayesInference/MCMC.py +++ b/BayesValidRox/BayesInference/MCMC.py @@ -13,6 +13,7 @@ from multiprocessing import Pool import scipy.stats as st from scipy.linalg import cholesky as chol import warnings +import time class MCMC(): """ diff --git a/BayesValidRox/surrogate_models/RegressionFastARD.py b/BayesValidRox/surrogate_models/RegressionFastARD.py index b6d8403d5..162f1fa69 100755 --- a/BayesValidRox/surrogate_models/RegressionFastARD.py +++ b/BayesValidRox/surrogate_models/RegressionFastARD.py @@ -150,8 +150,8 @@ class RegressionFastARD(): ''' - def __init__( self, n_iter = 300, start=None, tol = 1e-3, fit_intercept = True, - copy_X = True, compute_score=False, verbose = False): + def __init__( self, n_iter=300, start=None, tol=1e-3, fit_intercept=True, + copy_X=True, compute_score=False, verbose=False): self.n_iter = n_iter self.start = start self.tol = tol @@ -238,7 +238,7 @@ class RegressionFastARD(): start = np.argmax(proj) active[start] = True A[start] = XXd[start]/( proj[start] - var_y) - + warning_flag = 0 scores_ = [] for i in range(self.n_iter): @@ -277,7 +277,8 @@ class RegressionFastARD(): if self.verbose: print(('Iteration: {0}, number of features ' - 'in the model: {1}').format(i,np.sum(active))) + 'in the model: {1}').format(i,np.sum(active))) + if converged or i == self.n_iter - 1: if converged and self.verbose: print('Algorithm converged !') diff --git a/BayesValidRox/surrogate_models/surrogate_models.py b/BayesValidRox/surrogate_models/surrogate_models.py index 7334412fa..9342cb0fc 100644 --- a/BayesValidRox/surrogate_models/surrogate_models.py +++ b/BayesValidRox/surrogate_models/surrogate_models.py @@ -505,7 +505,7 @@ class aPCE: elif RegMethod == 'FastARD': clf_poly = RegressionFastARD(start=startBasisIndices,fit_intercept=False,compute_score=compute_score, - n_iter = 1000, tol= 1e-3) + n_iter=1500, tol=1e-3) elif RegMethod == 'LARS': clf_poly = linear_model.Lars(fit_intercept=False) -- GitLab