def test_ladle_partition(self): np.random.seed(42) df = np.random.normal(size=(10,3)) weights = np.ones((10,1)) / 10 e, W = ss.active_subspace(df, weights) ssmethod = lambda X, f, df, weights: ss.active_subspace(df, weights) e_br, sub_br, li_F = ss.bootstrap_ranges(e, W, None, None, df, weights, ssmethod, nboot=10) d = ss.ladle_partition(e, li_F)
def test_bootstrap_ranges_1(self): data = helper.load_test_npz('test_spec_decomp_1.npz') df0, e0, W0 = data['df'], data['e'], data['W'] np.random.seed(42) e_br, sub_br = ss.bootstrap_ranges(df0, e0, W0, n_boot=100) data_br = helper.load_test_npz('test_spec_br_1.npz') np.testing.assert_equal(e_br, data_br['e_br']) np.testing.assert_equal(sub_br, data_br['sub_br'])
def test_bootstrap_ranges(self): data = helper.load_test_npz('test_spec_decomp.npz') df, e, W = data['df'], data['e'], data['W'] np.random.seed(1234) e_br, sub_br = ss.bootstrap_ranges(df, e, W, n_boot=100) data = helper.load_test_npz('test_spec_br.npz') np.testing.assert_equal(e_br, data['e_br']) np.testing.assert_equal(sub_br, data['sub_br'])
def test_errbnd_partition(self): np.random.seed(42) df = np.random.normal(size=(10,3)) weights = np.ones((10,1)) / 10 e, W = ss.active_subspace(df, weights) ssmethod = lambda X, f, df, weights: ss.active_subspace(df, weights) e_br, sub_br, li_F = ss.bootstrap_ranges(e, W, None, None, df, weights, ssmethod, nboot=10) sub_err = sub_br[:,1].reshape((2, 1)) d = ss.errbnd_partition(e, sub_err)
def test_bootstrap_ranges_0(self): data = helper.load_test_npz('test_spec_decomp_0.npz') df0, e0, W0 = data['df'], data['e'], data['W'] np.random.seed(42) e_br, sub_br = ss.bootstrap_ranges(df0, e0, W0, n_boot=100) if self.writeData: np.savez('data/test_spec_br_0', e_br=e_br, sub_br=sub_br) data_br = helper.load_test_npz('test_spec_br_0.npz') np.testing.assert_almost_equal(e_br, data_br['e_br']) np.testing.assert_almost_equal(sub_br, data_br['sub_br'])
def test_bootstrap_ranges(self): np.random.seed(42) X = np.random.normal(size=(50,3)) f = np.random.normal(size=(50,1)) df = np.random.normal(size=(50,3)) weights = np.ones((50,1)) / 50 e, W = ss.active_subspace(df, weights) ssmethod = lambda X, f, df, weights: ss.active_subspace(df, weights) d = ss.bootstrap_ranges(e, W, None, None, df, weights, ssmethod, nboot=10) e, W = ss.normalized_active_subspace(df, weights) ssmethod = lambda X, f, df, weights: ss.normalized_active_subspace(df, weights) d = ss.bootstrap_ranges(e, W, None, None, df, weights, ssmethod, nboot=10) e, W = ss.active_subspace_x(X, df, weights) ssmethod = lambda X, f, df, weights: ss.active_subspace_x(X, df, weights) d = ss.bootstrap_ranges(e, W, X, None, df, weights, ssmethod, nboot=10) e, W = ss.normalized_active_subspace(df, weights) ssmethod = lambda X, f, df, weights: ss.normalized_active_subspace(df, weights) d = ss.bootstrap_ranges(e, W, None, None, df, weights, ssmethod, nboot=10) e, W = ss.swarm_subspace(X, f, weights) ssmethod = lambda X, f, df, weights: ss.swarm_subspace(X, f, weights) d = ss.bootstrap_ranges(e, W, X, f, None, weights, ssmethod, nboot=10) e, W = ss.ols_subspace(X, f, weights) ssmethod = lambda X, f, df, weights: ss.ols_subspace(X, f, weights) d = ss.bootstrap_ranges(e, W, X, f, None, weights, ssmethod, nboot=10) e, W = ss.qphd_subspace(X, f, weights) ssmethod = lambda X, f, df, weights: ss.qphd_subspace(X, f, weights) d = ss.bootstrap_ranges(e, W, X, f, None, weights, ssmethod, nboot=10) e, W = ss.sir_subspace(X, f, weights) ssmethod = lambda X, f, df, weights: ss.sir_subspace(X, f, weights) d = ss.bootstrap_ranges(e, W, X, f, None, weights, ssmethod, nboot=10) e, W = ss.phd_subspace(X, f, weights) ssmethod = lambda X, f, df, weights: ss.phd_subspace(X, f, weights) d = ss.bootstrap_ranges(e, W, X, f, None, weights, ssmethod, nboot=10) e, W = ss.save_subspace(X, f, weights) ssmethod = lambda X, f, df, weights: ss.save_subspace(X, f, weights) d = ss.bootstrap_ranges(e, W, X, f, None, weights, ssmethod, nboot=10) #### UNDER CONSTRUCTION #e, W = ss.mave_subspace(X, f, weights) #ssmethod = lambda X, f, df, weights: ss.mave_subspace(X, f, weights) #d = ss.bootstrap_ranges(e, W, X, f, None, weights, ssmethod, nboot=10) e, W = ss.opg_subspace(X, f, weights) ssmethod = lambda X, f, df, weights: ss.opg_subspace(X, f, weights) d = ss.bootstrap_ranges(e, W, X, f, None, weights, ssmethod, nboot=10)