def test_sdg_likelihood_categorical(): sdg = DataGenerator(10, ['categorical']*2, view_weights=1) x = [0, 1, 2] lls = sdg.log_likelihood(x, 0) assert len(lls) == 3 assert lls.shape == (3,)
def test_sdg_likelihood_categorical(): sdg = DataGenerator(10, ['categorical'] * 2, view_weights=1) x = [0, 1, 2] lls = sdg.log_likelihood(x, 0) assert len(lls) == 3 assert lls.shape == (3, )
def test_sdg_likelihood_continuous(): sdg = DataGenerator(10, ['continuous']*2, view_weights=1) x = np.linspace(0, 6, 10) lls = sdg.log_likelihood(x, 0) assert len(lls) == 10 assert lls.shape == (10,)
def test_sdg_likelihood_continuous(): sdg = DataGenerator(10, ['continuous'] * 2, view_weights=1) x = np.linspace(0, 6, 10) lls = sdg.log_likelihood(x, 0) assert len(lls) == 10 assert lls.shape == (10, )
def test_sdg_init_dual_mixed_two_view(dtype): sdg = DataGenerator(10, [dtype] * 3, view_weights=2) assert sdg.df.shape == ( 10, 3, ) assert min(sdg._colpart) == 0 assert max(sdg._colpart) == 1
def gen_data_and_engine(n_rows, n_cols, n_cats, cat_sep, n_models, n_iter): dg = DataGenerator(n_rows, ['continuous'] * n_cols, cat_weights=n_cats, cat_sep=cat_sep, seed=1337) engine = Engine(dg.df, use_mp=False) engine.init_models(n_models) engine.run(n_iter) return dg, engine
def test_sdg_init_single_categorical(): sdg = DataGenerator(10, ['categorical']) assert sdg.df.shape == ( 10, 1, ) assert sdg.df[0].dtype == 'int' assert len(sdg._params) == 1 assert len(sdg._params[0]) == 2
def test_sdg_init_single_continuous(): sdg = DataGenerator(10, ['continuous']) assert sdg.df.shape == ( 10, 1, ) assert sdg.df[0].dtype == 'float' assert len(sdg._params) == 1 assert len(sdg._params[0]) == 2
def test_sdg_init_dual_mixed(): sdg = DataGenerator(10, ['continuous', 'categorical']) assert sdg.df.shape == ( 10, 2, ) assert sdg.df[0].dtype == 'float' assert sdg.df[1].dtype == 'int' assert len(sdg._params) == 2 assert len(sdg._params[0]) == 2 assert len(sdg._params[1]) == 2
def test_sdg_init_dual_continuous(): sdg = DataGenerator(10, ['continuous'] * 2) assert sdg.df.shape == ( 10, 2, ) assert sdg.df[0].dtype == 'float' assert sdg.df[1].dtype == 'float' assert len(sdg._params) == 2 assert len(sdg._params[0]) == 2 assert len(sdg._params[1]) == 2
def test_sdg_init_dual_categorical(): sdg = DataGenerator(10, ['categorical'] * 2) assert sdg.df.shape == ( 10, 2, ) assert sdg.df[0].dtype == 'int' assert sdg.df[1].dtype == 'int' assert len(sdg._params) == 2 assert len(sdg._params[0]) == 2 assert len(sdg._params[1]) == 2
def gen_data_and_engine(n_rows, n_cols, n_cats, cat_sep, n_models, n_iter): dg = DataGenerator(n_rows, ['categorical'] * n_cols, cat_weights=n_cats, cat_sep=cat_sep, seed=1337) col_md = {'dtype': 'categorical', 'values': [0, 1, 2, 3, 4]} md = dict(( col, col_md, ) for col in range(n_cols)) engine = Engine(dg.df, metadata=md, use_mp=False) engine.init_models(n_models) engine.run(n_iter) return dg, engine