-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetTIME_predict.py
More file actions
163 lines (150 loc) · 4.28 KB
/
NetTIME_predict.py
File metadata and controls
163 lines (150 loc) · 4.28 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import argparse
from NetTIME import PredictWorkflow
######## User Input ########
parser = argparse.ArgumentParser(
"Make predictions using a NetTIME model checkpoint."
)
# Prediction parameters
parser.add_argument(
"--batch_size",
type=int,
default=2700,
help="Prediction batch size. Default: 2700",
)
parser.add_argument(
"--num_workers",
type=int,
default=10,
help="Number of workers used to perform multi-process data loading. "
"Default: 10",
)
parser.add_argument(
"--seed", type=int, default=1111, help="Random seed. Default: 1111"
)
parser.add_argument(
"--model_config",
type=str,
default=None,
help="Specify an alternative path to model .config file.",
)
parser.add_argument(
"--best_ckpt",
type=str,
default=None,
help="Specify an alternative path to a best model checkpoint .ckpt file or "
"a best checkpoint evaluation .json file, which will be used to make "
"predictions.",
)
parser.add_argument(
"--eval_metric",
type=str,
default=None,
help="If BEST_CKPT is a .ckpt file, specify the evaluation metric used to "
"select BEST_CKPT as the best checkpoint.",
)
# Data
parser.add_argument(
"--output_key",
type=str,
default=["output_conserved"],
nargs="+",
help="A list of keys specifying the types of target labels to use for "
"prediction. Default: output_conserved",
)
parser.add_argument(
"--dataset",
type=str,
default="data/datasets/training_example/validation_minOverlap200_maxUnion600.h5",
help="Path to prediction data. Default: "
"data/datasets/training_example/validation_minOverlap200_maxUnion600.h5",
)
parser.add_argument(
"--dtype",
type=str,
default="TEST",
help="Dataset type. Default: TEST.",
)
parser.add_argument(
"--index_file",
type=str,
default="data/embeddings/example.pkl",
help="Path to a pickle file containing indices for TF and cell type labels."
"Default: data/embeddings/example.pkl",
)
parser.add_argument(
"--exclude_groups",
type=str,
default=None,
nargs="+",
help="When target labels specified by OUTPUT_KEY in DATASET are available, "
"specify a list of group names to be excluded from prediction. Default: "
"None, all conditions in DATASET OUTPUT_KEY are included during prediction.",
)
parser.add_argument(
"--include_groups",
type=str,
default=None,
nargs="+",
help="When target labels specified by OUTPUT_KEY in DATASET are available, "
"specify a list of group names to be included for prediction. Default: "
"None, all conditions in DATASET OUTPUT_KEY are included during prediction.",
)
parser.add_argument(
"--no_target",
action="store_true",
help="Specify this flag when target labels are not available.",
)
parser.add_argument(
"--predict_groups",
type=str,
default=None,
nargs="+",
help="When target labels are not available, specify a list of group names "
"for which to make predictions. Default: None, no condition is included.",
)
# Save
parser.add_argument(
"--output_dir",
type=str,
default="experiments/",
help="Root directory for saving experiment results. Default: experiments/",
)
parser.add_argument(
"--experiment_name",
type=str,
default="training_example",
help="experiment name.",
)
parser.add_argument(
"--result_dir",
type=str,
default=None,
help="Specify an alternative location to save prediction files.",
)
args = parser.parse_args()
######## Configure workflow ########
workflow = PredictWorkflow()
# Prediction parameters
workflow.batch_size = args.batch_size
workflow.num_workers = args.num_workers
workflow.seed = args.seed
workflow.model_config = args.model_config
workflow.best_ckpt = args.best_ckpt
workflow.eval_metric = args.eval_metric
# Data
workflow.output_key = args.output_key
workflow.dataset = args.dataset
workflow.dtype = args.dtype
workflow.index_file = args.index_file
workflow.exclude_groups = args.exclude_groups
workflow.include_groups = args.include_groups
workflow.no_target = args.no_target
workflow.predict_groups = args.predict_groups
# Save
workflow.output_dir = args.output_dir
workflow.experiment_name = args.experiment_name
workflow.result_dir = args.result_dir
# Args
workflow.args = args
######## Model Run ########
workflow.run()