-
Notifications
You must be signed in to change notification settings - Fork 19
/
example_iteration_script.py
60 lines (45 loc) · 1.83 KB
/
example_iteration_script.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 pickle as pkl
import design_bench as db
import numpy as np
from design_bench.oracles.feature_extractors.morgan_fingerprint_features import MorganFingerprintFeatures
if __name__ == "__main__":
with open("type_assay_pairs.pkl", "rb") as f:
type_assay_pairs = pkl.load(f)
all_rank_corr = []
for type_name, assay_name in type_assay_pairs:
task = db.make(
'ChEMBLMorganFingerprint-FullyConnected-v0',
dataset_kwargs=dict(
max_samples=None,
distribution=None,
max_percentile=50,
min_percentile=0,
assay_chembl_id=assay_name,
standard_type=type_name),
oracle_kwargs=dict(
noise_std=0.0,
max_samples=None,
distribution=None,
max_percentile=100,
min_percentile=0,
feature_extractor=MorganFingerprintFeatures(dtype=np.float32),
model_kwargs=dict(
hidden_size=512,
activation='relu',
num_layers=2,
epochs=5,
shuffle_buffer=5000,
learning_rate=0.0001),
split_kwargs=dict(
val_fraction=0.1,
subset=None,
shard_size=50000,
to_disk=True,
disk_target=f"chembl-{type_name}-{assay_name}/split",
is_absolute=False))
)
print(type_name, assay_name,
task.oracle.params['rank_correlation'])
all_rank_corr.append(task.oracle.params['rank_correlation'])
best_type_name, best_assay_name = \
type_assay_pairs[np.argmax(np.array(all_rank_corr))]