forked from facebookresearch/DomainBed
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mysresults_ensemble.py
64 lines (33 loc) · 2.06 KB
/
mysresults_ensemble.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import pandas as pd
import numpy as np
total_domains = 4
ONLY_ENSEMBLE_OBS=False
if ONLY_ENSEMBLE_OBS:
for test_env in range(total_domains):
out_file = 'Inevnio_withoutaug/VLCS_M3/env'+str(test_env)+'/indiv_ensemble_no_beta/out_eval copy.txt'
out_df = pd.read_fwf(out_file)
train_envs = np.setdiff1d(np.arange(total_domains),test_env)
train_out_split_names= ['env'+str(i)+'_out_ens_acc' for i in train_envs]
train_in_split_names= ['env'+str(i)+'_in_ens_acc' for i in train_envs]
test_ensemble_name= 'unobs_env'+str(test_env)+'_in_ens_acc'
test_ensemble_out_name= 'unobs_env'+str(test_env)+'_out_ens_acc'
#step = out_df['step']
validation_acc= np.mean(np.stack([out_df[i].values for i in train_in_split_names+train_out_split_names]) ,axis=0)
max_val_idx= np.argmax(validation_acc)
max_val_idx_1 = np.argmax( out_df[test_ensemble_out_name].values)
print('test_train_Domain_val','test_oracle',out_df[test_ensemble_name].iloc[max_val_idx]*100,out_df[test_ensemble_name].iloc[max_val_idx_1]*100)
else:
for test_env in range(total_domains):
out_file = 'Inevnio_withoutaug/ColoredMNIST_M3/env'+str(test_env)+'/indiv_ensemble_no_beta/out copy.txt'
out_df= pd.read_fwf(out_file)
out_df= out_df[out_df['step']<5001]
out_df= out_df[out_df['step']>1]
train_envs = np.setdiff1d(np.arange(total_domains),test_env)
train_out_split_names= ['env'+str(i)+'_out_acc' for i in train_envs]
test_ensemble_name= 'env'+str(test_env)+'_in_ens_acc'
test_ensemble_out_name= 'env'+str(test_env)+'_out_ens_acc'
epochs= out_df['epoch']
validation_acc= np.sum(np.stack([out_df[i].values for i in train_out_split_names]) ,axis=0)/3.
max_val_idx= np.argmax(validation_acc)
max_val_idx_1 = np.argmax( out_df[test_ensemble_out_name].values)
print('test_train_Domain_val','test_oracle',out_df[test_ensemble_name].iloc[max_val_idx]*100,out_df[test_ensemble_name].iloc[max_val_idx_1]*100)