forked from ChangwenXu98/TransPolymer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_vocab.py
42 lines (30 loc) · 1.85 KB
/
check_vocab.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
import pandas as pd
import numpy as np
import pdb
def check_smiles():
ood_smiles = pd.read_csv("./data/ood_multi_comp_comb.csv")
random_smiles = pd.read_csv("./data/random_train_multi_comp.csv")
ood_smiles['combined_sm'] = ood_smiles['solv_comb_sm'] + ood_smiles['salt_sm']
ood_unique = ood_smiles['combined_sm'].unique()
random_smiles['combined_sm'] = random_smiles['solv_1_sm'] + random_smiles['solv_2_sm'] + random_smiles['solv_3_sm'] + random_smiles['solv_4_sm'] + random_smiles['salt_sm']
random_unique = random_smiles['combined_sm'].unique()
ood_unique_list = ood_unique.tolist()
random_unique_list = random_unique.tolist()
diff = np.setdiff1d(ood_unique_list,random_unique_list)
def check_discrete():
vocab = pd.read_csv('./data/vocab/vocab_sup_PE_I.csv')
random_train = pd.read_csv("./data/random_train_multi_add_quantile.csv")
random_train = random_train.round(2)
random_train['combined'] = random_train['solv_ratio_1'] + random_train['solv_ratio_2'] + random_train['solv_ratio_3'] + random_train['solv_ratio_4'] + random_train['mol_wt_solv_1'] + random_train['mol_wt_solv_2'] + random_train['mol_wt_solv_3'] + random_train['mol_wt_solv_4'] + random_train['conc_salt'] + random_train['temperature']
random_train_unique = random_train['combined'].unique()
random_train_unique_list = random_train_unique.tolist()
vocab_unique_list = vocab['$'].tolist()
diff = np.setdiff1d(random_train_unique_list, vocab_unique_list)
new_vocab = list(set(random_train_unique_list) | set(vocab_unique_list))
df = pd.DataFrame(new_vocab)
df_with_formatted_floats = df.applymap(lambda x: '{:.2f}'.format(x) if isinstance(x, float) else x)
df_with_formatted_floats.to_csv('./data/vocab/vocab_random_train_decimal_2_quantile.csv', index=False)
def main():
check_discrete()
if __name__ == "__main__":
main()