Example #1
0
                                      })
 val_target_stat = np.exp(val_target_logit)
 val_target_AUC = roc_auc_score(yt_val, val_target_stat)
 test_auc_list.append(test_target_AUC)
 val_auc_list.append(val_target_AUC)
 np.savetxt(DA_model_folder + '/test_auc.txt', test_auc_list)
 np.savetxt(DA_model_folder + '/val_auc.txt', val_auc_list)
 # loss
 M_loss_list.append(
     M_loss
 )  # ;D_loss_list.append(D_loss);sC_loss_list.append(sC_loss)
 np.savetxt(DA_model_folder + '/MMD_loss.txt', M_loss_list)
 # np.savetxt(DA_model_folder+'/G_loss.txt',G_loss_list);
 np.savetxt(DA_model_folder + '/src_clf_loss.txt', sC_loss_list)
 # print and plot results
 print_block(symbol='-', nb_sybl=60)
 print_yellow(os.path.basename(DA_model_folder))
 if nb_trg_labels > 0:
     train_auc_list.append(train_target_AUC)
     tC_loss_list.append(tC_loss)
     np.savetxt(os.path.join(DA_model_folder, 'trg_train_auc.txt'),
                train_auc_list)
     np.savetxt(os.path.join(DA_model_folder, 'trg_clf_loss.txt'),
                tC_loss_list)
     print_green(
         'AUC: T-test {0:.4f}, T-valid {1:.4f}, T-train {2:.4f}, S-test: {3:.4f}'
         .format(test_target_AUC, val_target_AUC, train_target_AUC,
                 test_source_AUC))
     print_yellow(
         'Loss: D:{:.4f}, S:{:.4f}, T:{:.4f}, Iter:{:}'.format(
             M_loss, sC_loss, tC_loss, iteration))
Example #2
0
			test_source_logit = model_test(sess, source_logit, xs, Xs_tst)
# 			test_source_logit=source_logit.eval(session=sess,feed_dict={xs:Xs_tst,g_training:False,d_training:False})
			test_source_stat=np.exp(test_source_logit);test_source_AUC=roc_auc_score(ys_tst,test_source_stat);src_test_list.append(test_source_AUC)
# 			test_target_logit = target_logit.eval(session=sess,feed_dict={xt:Xt_tst, g_training: False, d_training: False})
			test_target_logit = model_test(sess, target_logit, xt, Xt_tst)
			test_target_stat = np.exp(test_target_logit);test_target_AUC = roc_auc_score(yt_tst, test_target_stat)
			val_target_logit = target_logit.eval(session=sess,feed_dict={xt:Xt_val, g_training: False})
			val_target_stat = np.exp(val_target_logit);val_target_AUC = roc_auc_score(yt_val, val_target_stat)
			test_auc_list.append(test_target_AUC);val_auc_list.append(val_target_AUC)
			np.savetxt(DA_model_folder+'/test_auc.txt', test_auc_list);np.savetxt(DA_model_folder+'/val_auc.txt', val_auc_list)
			# loss
			M_loss_list.append(M_loss)# ;D_loss_list.append(D_loss);sC_loss_list.append(sC_loss)
			np.savetxt(DA_model_folder+'/MMD_loss.txt',M_loss_list);# np.savetxt(DA_model_folder+'/G_loss.txt',G_loss_list);
			np.savetxt(DA_model_folder+'/src_clf_loss.txt',sC_loss_list)
			# print and plot results
			print_block(symbol = '-', nb_sybl = 60);print_yellow(os.path.basename(DA_model_folder))
			if nb_trg_labels > 0:
				train_auc_list.append(train_target_AUC);tC_loss_list.append(tC_loss)
				np.savetxt(os.path.join(DA_model_folder,'trg_train_auc.txt'), train_auc_list)
				np.savetxt(os.path.join(DA_model_folder,'trg_clf_loss.txt'),tC_loss_list)
				print_green('AUC: T-test {0:.4f}, T-valid {1:.4f}, T-train {2:.4f}, S-test: {3:.4f}'.format(test_target_AUC, val_target_AUC, train_target_AUC, test_source_AUC))
				print_yellow('Loss: D:{:.4f}, S:{:.4f}, T:{:.4f}, Iter:{:}'.format(M_loss, sC_loss, tC_loss, iteration))
				plot_LOSS(DA_model_folder+'/loss_{}.png'.format(DA_model_name), M_loss_list, sC_loss_list, tC_loss_list)
				plot_loss(DA_model_folder, M_loss_list, M_loss_list, DA_model_folder+'/MMD_loss_{}.png'.format(DA_model_name))
				plot_src_trg_AUCs(DA_model_folder+'/AUC_src_{}.png'.format(DA_model_name), train_auc_list, val_auc_list, test_auc_list, src_test_list)
				plot_AUCs(DA_model_folder+'/AUC_trg_{}.png'.format(DA_model_name), train_auc_list, val_auc_list, test_auc_list)
			else:
				print_green('AUC: T-test {0:.4f}, T-valid {1:.4f}, S-test: {2:.4f}'.format(test_target_AUC, val_target_AUC, test_source_AUC))
				print_yellow('Loss: D:{:.4f}, S:{:.4f}, Iter:{:}'.format(M_loss, sC_loss, iteration))
				plot_loss(DA_model_folder, M_loss_list, sC_loss_list, DA_model_folder+'/loss_{}.png'.format(DA_model_name))
				plot_loss(DA_model_folder, M_loss_list, M_loss_list, DA_model_folder+'/MMD_lOSS_{}.png'.format(DA_model_name))