def cs_hdmr_modeler(inputs, outputs, ord_cap=3, deg_cap=3, independent=False): d = inputs.shape[1] syms = [sympy.Symbol('x' + str(i+1)) for i in range(d)] if independent: def get_range(i): in_i = np.array([x[i] for x in inputs]) center = np.sum(in_i) / len(in_i) var = np.var(in_i) d = np.sqrt(12*var) s = 2*center b = (s + d) / 2 a = s - b return [a, b] ranges = [get_range(i) for i in range(d)] basis_dict = sym_poly_utils.uniform_honb( ranges, inputs, syms, ord_cap=ord_cap, deg_cap=deg_cap ) else: basis_dict = sym_poly_utils.sample_honb( inputs, syms, ord_cap=ord_cap, deg_cap=deg_cap ) expansion = cs_hdmr_expansion(inputs, outputs, basis_dict) return expansion
def _test_sample_basis_hon(self, row_generator): syms = [sympy.Symbol('x' + str(i + 1)) for i in range(self.d)] sample = np.array([row_generator() for i in range(self.N)]) basis = sym_poly_utils.sample_honb(sample, syms) self._validate_basis(sample, basis)
def _test_sample_basis_hon(self, row_generator): syms = [sympy.Symbol('x' + str(i+1)) for i in range(self.d)] sample = np.array( [row_generator() for i in range(self.N)] ) basis = sym_poly_utils.sample_honb(sample, syms) self._validate_basis(sample, basis)