def test_corr_poly_1(self): """ Source: "General formulation of HDMR component functions with independent and correlated variables", Rabitz/Li, J Math Chem 2011. Two identical copies of the polynomial taken and added together (on distinct sets of variables) to increase dimensionality to make this a more interesting example. """ mu = np.array([1.0, 2.0, 3.0, 1.0, 2.0, 3.0]) cov = np.array([ [1.0, 1.0, 0.0, 0.0, 0.0, 0.0], [0.5, 1.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 1.0, 1.0, 0.0], [0.0, 0.0, 0.0, 0.5, 1.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 1.0] ]) sample_fn = model_validation.multi_gaussian_sampler(mu, cov) test_fn = test_functions.gen_corr_poly_1(mu) m = functools.partial(self.modeler, ord_cap=3, deg_cap=4) print "Cross-validation relative L2 errors", model_validation.modeler_function_l2_errors( m, 200, sample_fn, test_fn )
import model_validation logging.basicConfig() mu = np.array([1.0, 2.0, 3.0, 1.0, 2.0, 3.0]) cov = np.array( [ [1.0, 1.0, 0.0, 0.0, 0.0, 0.0], [0.5, 1.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 1.0, 1.0, 0.0], [0.0, 0.0, 0.0, 0.5, 1.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 1.0] ] ) sample_fn = model_validation.multi_gaussian_sampler(mu, cov) test_poly = test_functions.gen_corr_poly_1(mu) n_list = [140] sample_divisions = 12 out_file = proj_utils.OUT_DIR / 'corr_conv.csv' def main(): with open(out_file, 'w') as f: writer = csv.writer(f) modeler = functools.partial( cs_hdmr.cs_hdmr_modeler, ord_cap=2, deg_cap=5 )
import logging import cProfile import proj_utils import csv import tests.test_functions as test_functions import numpy as np import model_validation logging.basicConfig() mu = np.array([1.0, 2.0, 3.0, 1.0, 2.0, 3.0]) cov = np.array([[1.0, 1.0, 0.0, 0.0, 0.0, 0.0], [0.5, 1.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 1.0, 1.0, 0.0], [0.0, 0.0, 0.0, 0.5, 1.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 1.0]]) sample_fn = model_validation.multi_gaussian_sampler(mu, cov) test_poly = test_functions.gen_corr_poly_1(mu) n_list = [140] sample_divisions = 12 out_file = proj_utils.OUT_DIR / 'corr_conv.csv' def main(): with open(out_file, 'w') as f: writer = csv.writer(f) modeler = functools.partial(cs_hdmr.cs_hdmr_modeler, ord_cap=2, deg_cap=5)