roc_max.append(roc_auc_score(y_test, comb_by_max)) prn_max.append(precision_n_scores(y_test, comb_by_max)) print('ite', t + 1, 'comb by max,', 'ROC:', roc_auc_score(y_test, comb_by_max), 'precision@n:', precision_n_scores(y_test, comb_by_max)) # combination by aom comb_by_aom = aom(test_scores_norm, 5, 20) roc_aom.append(roc_auc_score(y_test, comb_by_aom)) prn_aom.append(precision_n_scores(y_test, comb_by_aom)) print('ite', t + 1, 'comb by aom,', 'ROC:', roc_auc_score(y_test, comb_by_aom), 'precision@n:', precision_n_scores(y_test, comb_by_aom)) # combination by moa comb_by_moa = moa(test_scores_norm, 5, 20) roc_moa.append(roc_auc_score(y_test, comb_by_moa)) prn_moa.append(precision_n_scores(y_test, comb_by_moa)) print('ite', t + 1, 'comb by moa,', 'ROC:', roc_auc_score(y_test, comb_by_moa), 'precision@n:', precision_n_scores(y_test, comb_by_moa)) print() ########################################################################## print('summary of {ite} iterations'.format(ite=ite)) print('comb by mean, ROC: {roc}, precision@n: {prn}'.format( roc=np.mean(roc_mean), prn=np.mean(prn_mean))) print('comb by max, ROC: {roc}, precision@n: {prn}'.format( roc=np.mean(roc_max), prn=np.mean(prn_max))) print('comb by aom, ROC: {roc}, precision@n: {prn}'.format(
axis=1) test_target_list.extend( [target_test_weighted_pear, target_test_weighted_euc]) method_list.extend([ 'w_mean_pear', 'w_mean_euc', ]) # generate threshold sum target_test_threshold = np.sum(test_scores_norm.clip(0), axis=1) test_target_list.append(target_test_threshold) method_list.append('threshold') # generate average of maximum (AOM) and maximum of average (MOA) target_test_aom = aom(test_scores_norm, n_buckets, n_clf) target_test_moa = moa(test_scores_norm, n_buckets, n_clf) test_target_list.extend([target_test_aom, target_test_moa]) method_list.extend(['aom', 'moa']) ################################################################### # use mean as the pseudo target for k in final_k_list: tree = KDTree(X_train_norm) dist_arr, ind_arr = tree.query(X_test_norm, k=k) m_list = [ 'a_dist_d', 'a_dist_r', 'a_dist_n', 'a_pear_d', 'a_pear_r', 'a_pear_n' ] # initialize different buckets pred_scores_best = np.zeros([X_test.shape[0], len(m_list)])