def _componentwise_distance(self, dx, small=False, opt=0): """ Compute the componentwise distance with respect to the correlation kernel Parameters ---------- dx : numpy.ndarray Distance matrix. small : bool, optional Compute the componentwise distance in small (n_components) dimension or in initial dimension. The default is False. opt : int, optional useless for MGP Returns ------- d : numpy.ndarray Component wise distance. """ if small: d = componentwise_distance(dx, self.options["corr"], self.options["n_comp"]) else: d = componentwise_distance(dx, self.options["corr"], self.nx) return d
def test_corr_derivatives(self): for ind, corr in enumerate(self.corr_def): # For every kernel self.corr_str[ind] = self.corr_def[ind] D = componentwise_distance(self.D, self.corr_str, self.X.shape[1]) k = corr(self.theta, D) K = np.eye(self.X.shape[0]) K[self.ij[:, 0], self.ij[:, 1]] = k[:, 0] K[self.ij[:, 1], self.ij[:, 0]] = k[:, 0] grad_norm_all = [] diff_norm_all = [] ind_theta = [] for i, theta_i in enumerate(self.theta): eps_theta = np.zeros(self.theta.shape) eps_theta[i] = self.eps k_dk = corr(self.theta + eps_theta, D) K_dk = np.eye(self.X.shape[0]) K_dk[self.ij[:, 0], self.ij[:, 1]] = k_dk[:, 0] K_dk[self.ij[:, 1], self.ij[:, 0]] = k_dk[:, 0] grad_eps = (K_dk - K) / self.eps dk = corr(self.theta, D, grad_ind=i) dK = np.zeros((self.X.shape[0], self.X.shape[0])) dK[self.ij[:, 0], self.ij[:, 1]] = dk[:, 0] dK[self.ij[:, 1], self.ij[:, 0]] = dk[:, 0] grad_norm_all.append(np.linalg.norm(dK)) diff_norm_all.append(np.linalg.norm(grad_eps)) ind_theta.append(r"$x_%d$" % i) self.assert_error(np.array(grad_norm_all), np.array(diff_norm_all), 1e-5, 1e-5) # from utils/smt_test_case.py
def _componentwise_distance(self, dx, opt=0, theta=None, return_derivative=False): if opt == 0: # Kriging step d = componentwise_distance( dx, self.options["corr"], self.nx, theta=theta, return_derivative=return_derivative, ) else: # KPLS step d = componentwise_distance_PLS( dx, self.options["corr"], self.options["n_comp"], self.coeff_pls, theta=theta, return_derivative=return_derivative, ) return d
def _componentwise_distance(self,dx,opt=0): if opt == 0: # Kriging step d = componentwise_distance(dx,self.options['corr'],self.nx) else: # KPLS step d = componentwise_distance_PLS(dx,self.options['corr'], self.options['n_comp'],self.coeff_pls) return d
def _componentwise_distance(self, dx, opt=0): # Modif for KPLSK model if opt == 0: # Kriging step d = componentwise_distance(dx, self.options["corr"], self.nx) else: # KPLS step d = super(MFKPLSK, self)._componentwise_distance(dx, opt) return d
def _componentwise_distance(self, dx, opt=0, theta=None, return_derivative=False): d = componentwise_distance( dx, self.options["corr"], self.nx, theta=theta, return_derivative=return_derivative, ) return d
def _componentwise_distance(self, dx, opt=0): d = componentwise_distance(dx, self.options["corr"], self.nx) return d
def _componentwise_distance(self,dx,opt=0): d = componentwise_distance(dx,self.options['corr'].__name__, self.nx) return d