text: import numpy as np
  from scipy import stats
  import os
  from util import load_print_results
  
  def st_test(dataset_name, result_dir='./results'):
      result_list = os.listdir(result_dir)
      dataset_name_len = len(dataset_name)
      all_results_items = []
      for result_item in result_list:
          if result_item[:dataset_name_len] in [dataset_name] and 'single_best' not in result_item and 'dbn' not in result_item and 'clas' not in result_item and 'dgcca' not in result_item and 'dsvdd_fused' not in result_item and 'mvae_fused' not in result_item and 'nus_wide_scene' not in result_item:
              all_results_items.append(result_item)
  
      all_results = {}
      for result_item in all_results_items:
          files = np.load(os.path.join(result_dir, result_item))
          file_names = files.files
          cur_results = [files[file_name] for file_name in file_names]
          all_results[result_item] = cur_results
  
      for i in range(len(file_names)):
          best_key = None
          best_val = 0
          for key in all_results.keys():
              if best_key is None:
                  best_key = key
                  best_val = all_results[key][i].mean()
              else:
                  cur_val = all_results[key][i].mean()
                  if cur_val > best_val:
                      best_val = cur_val
                      best_key = key
  
          # get statistical difference
          p_val_set = {}
          best_val_list = np.mean(all_results[best_key][i], axis=-1)
          for key in all_results.keys():
              cur_val_list = np.mean(all_results[key][i], axis=-1)
              p_val_set[key] = stats.ttest_ind(cur_val_list, best_val_list)[1]
              print('metric: {}, method: {}, performance: {:.4f}+-{:.4f}, p_val: {:.2f}'.format(file_names[i], key, np.mean(cur_val_list), np.std(cur_val_list), p_val_set[key]))
  
          print('\n')
  
  
  
  if __name__ == '__main__':
  
  
      st_test('ytface')
  
  