Пример #1
0
palette = sns.color_palette("bright", 2)
sns.scatterplot(DA_embedded[:, 0],
                DA_embedded[:, 1],
                hue=y_DA_list,
                legend='full',
                palette=palette)
plt.savefig(figure_folder + '/DA.png')

plt.clf()
sns.set(rc={'figure.figsize': (11.7, 8.27)})
palette = sns.color_palette("bright", 2)
sns.scatterplot(TO_embedded[:, 0],
                TO_embedded[:, 1],
                hue=y_TO_list,
                legend='full',
                palette=palette,
                markers='s')
plt.savefig(figure_folder + '/TO.png')

from helper_function import plot_feature_dist, plot_feature_pair_dist
plot_feature_dist(figure_folder + '/SO.png', SO_features, yt_test, 'SO')
plot_feature_dist(figure_folder + '/DA.png', DA_features, yt_test, 'DA')
plot_feature_dist(figure_folder + '/TO.png', target_features, yt_test, 'TO')

plot_feature_pair_dist(figure_folder + '/DA_TO.png',
                       DA_features,
                       target_features,
                       yt_test,
                       yt_test,
                       label=['DA', 'TO'])
Пример #2
0
             test_auc_list, val_auc_list, src_test_list,
             DA_model_folder + '/AUC_src_{}.png'.format(DA_model_name))
     plot_auc_iterations(
         test_auc_list, val_auc_list,
         DA_model_folder + '/AUC_Final_{}.png'.format(DA_model_name))
     if best_val_auc < val_target_AUC:
         best_val_auc = val_target_AUC
         target_saver.save(sess, DA_model_folder + '/target_best')
         np.savetxt(os.path.join(DA_model_folder, 'test_stat.txt'),
                    test_target_stat)
         np.savetxt(os.path.join(DA_model_folder, 'test_best_auc.txt'),
                    [test_target_AUC])
         print_red('Update best:' + DA_model_folder)
     if iteration % 1000 == 0:
         indices = np.random.randint(0, Xs_tst.shape[0], 100)
         source_feat = h_src.eval(session=sess,
                                  feed_dict={
                                      xs: Xs_tst[indices, ],
                                      g_training: False
                                  })
         target_feat = h_trg.eval(session=sess,
                                  feed_dict={
                                      xt: Xt_tst[indices, ],
                                      g_training: False
                                  })
         plot_feature_pair_dist(
             DA_model_folder +
             '/feat_{}_iter_{}.png'.format(DA_model_name, iteration),
             np.squeeze(source_feat), np.squeeze(target_feat),
             ys_tst[indices], yt_tst[indices], ['source', 'target'])
 gc.collect()
Пример #3
0
                fig_size=(10, 10))
 # save models
 if iteration % 100 == 0:
     target_saver.save(sess,
                       DA_model_folder + '/target',
                       global_step=iteration)
 if best_val_auc < val_target_AUC:
     best_val_auc = val_target_AUC
     target_saver.save(sess, DA_model_folder + '/target_best')
     np.savetxt(os.path.join(DA_model_folder, 'test_stat.txt'),
                test_target_stat)
     np.savetxt(os.path.join(DA_model_folder, 'test_best_auc.txt'),
                [test_target_AUC])
     print_red('Update best:' + DA_model_folder)
 if iteration % 10000 == 0:
     source_feat = h_src.eval(session=sess,
                              feed_dict={
                                  xs: Xs_tst,
                                  is_training: False,
                                  dis_training: False
                              })
     target_feat = h_trg.eval(session=sess,
                              feed_dict={
                                  xt: Xt_tst,
                                  is_training: False,
                                  dis_training: False
                              })
     plot_feature_pair_dist(
         DA_model_folder + '/feat_{}.png'.format(DA_model_name),
         np.squeeze(source_feat), np.squeeze(target_feat), ys_tst,
         yt_tst, ['source', 'target'])