def test_update_fit_group_with_groupwise_dist_01(self): """ test with generic distance metrics """ # load test data user_ids, user_profile_df, user_connection_df = load_sample_test_data() # definte test data fit_group = {0: ['a', 'b', 'c'], 1: ['d', 'e']} fit_pvals = {0: [1, 1, 1], 1: [1, 1]} dist_metrics = {0: [1, 1, 1], 1: [1, 1, 1]} dist_memory_container = [{}, {}] new_fit_group, new_fit_pvals, unfit_group = _update_fit_group_with_groupwise_dist( dist_metrics, fit_group, fit_pvals, user_ids, user_profile_df, user_connection_df, dist_memory_container, is_directed=False, ks_alpha=0.05) print( "--- update_fit_group_with_groupwise (with: generic distance metrics) ---" ) print("new 1st fit_group: {}".format(new_fit_group[0])) print("new 2nd fit_group: {}".format(new_fit_group[1])) print("new 1st fit_pval: {}".format(new_fit_pvals[0])) print("new 2nd fit_pval: {}".format(new_fit_pvals[1])) is_ok = True self.assertTrue(is_ok, True)
def test_update_fit_group_with_groupwise_dist_02(self): """ test with generic distance metrics """ # load test data user_ids, user_profile_df, user_connection_df = load_sample_test_data() # definte test data fit_group = {0: ['a', 'b', 'c'], 1: ['d', 'e']} fit_pvals = {0: [1, 1, 1], 1: [1, 1]} new_dist_metrics = {0: [0, 1, 0], 1: [0, 0, 1]} new_fit_group, new_fit_pvals, unfit_group = _update_fit_group_with_groupwise_dist(new_dist_metrics, fit_group, fit_pvals, user_ids, user_profile_df, user_connection_df, ks_alpha=0.05) print("--- update_fit_group_with_groupwise (with: learned distance metrics) ---") print("new 1st fit_group: {}".format(new_fit_group[0])) print("new 2nd fit_group: {}".format(new_fit_group[1])) print("new 1st fit_pval: {}".format(new_fit_pvals[0])) print("new 2nd fit_pval: {}".format(new_fit_pvals[1])) is_ok = True self.assertTrue(is_ok, True)
def test_update_fit_group_with_groupwise_dist_01(self): """ test with generic distance metrics """ user_ids, user_profile_df, user_connection_df, true_group = load_simulated_test_data() # define test data n_feat = user_profile_df.shape[1] # a_group = [user_ids[i] for i, g in enumerate(true_group) if g == 0] b_group = [user_ids[i] for i, g in enumerate(true_group) if g == 1] fit_group = {0: a_group, 1: b_group} fit_pvals = {0: [1]*len(a_group), 1: [1] * len(b_group)} dist_metrics = {0: [0.49, 0.51, 0, 0, 0, 0], 1: [0, 0, 0, 0.88, 0.08, 0.04]} new_fit_group, new_fit_pvals, unfit_group = _update_fit_group_with_groupwise_dist(dist_metrics, fit_group, fit_pvals, user_ids, user_profile_df, user_connection_df, ks_alpha=0.05) print("--- update_fit_group_with_groupwise (with: correct distance metrics) ---") print("new 1st fit_group: {}".format(new_fit_group[0])) print("new 2nd fit_group: {}".format(new_fit_group[1])) print("new 1st fit_pval: {}".format(new_fit_pvals[0])) print("new 2nd fit_pval: {}".format(new_fit_pvals[1])) is_ok = True self.assertTrue(is_ok, True)
def test_update_fit_group_with_groupwise_dist_03(self): """ test with generic distance metrics """ user_ids, user_profile_df, user_connection_df, true_group = load_simulated_test_data( ) # define test data n_feat = user_profile_df.shape[1] # a_group = [user_ids[i] for i, g in enumerate(true_group) if g == 0] b_group = [user_ids[i] for i, g in enumerate(true_group) if g == 1] fit_group = {0: a_group, 1: b_group} fit_pvals = {0: [1] * len(a_group), 1: [1] * len(b_group)} dist_metrics = {0: [1] * n_feat, 1: [1] * n_feat} new_fit_group, new_fit_pvals, unfit_group = _update_fit_group_with_groupwise_dist( dist_metrics, fit_group, fit_pvals, user_ids, user_profile_df, user_connection_df, ks_alpha=0.05) print( "--- update_fit_group_with_groupwise (with: generic distance metrics) ---" ) print("new 1st fit_group: {}".format(new_fit_group[0])) print("new 2nd fit_group: {}".format(new_fit_group[1])) print("new 1st fit_pval: {}".format(new_fit_pvals[0])) print("new 2nd fit_pval: {}".format(new_fit_pvals[1])) is_ok = True self.assertTrue(is_ok, True)