-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_k_folds_tvt_bbbc021.py
68 lines (60 loc) · 2.91 KB
/
make_k_folds_tvt_bbbc021.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
61
62
63
64
65
66
67
68
from email.mime import image
from make_k_folds_tvt import MakeTVTSets
# Make K-folds, including their train and validation parts, with csv files as outpus
class MakeKFoldsTVTBBBC021(MakeTVTSets):
def __init__(self,
labels_path="/home/jovyan/Data/BBBC021/BBBC021_Labels.csv",
output_dir='/home/jovyan/Inputs/TEST_BBBC021_leave_one_out/',
include_groups=[], # Empty for everything included,
include_header="moa",
class_column_header="moa",
excluded_groups=[
["DMSO", "Cholesterol-lowering", "Eg5 inhibitors"]],
#excluded_groups = [["DMSO"]],
excluded_groups_headers=["moa"],
exclude_images_path="",
intact_group_header='compound',
unique_sample_headers=["ImageNumber"],
image_number_heading="ImageNumber",
k_folds="3",
divide_on_header='compound',
make_train_valid=True,
# 1 = 100%, Percentage of images remaining afte the test set has been excluded
valid_fraction=0.25,
leave_one_out=True,
make_unique_validation=True,
non_unique_divider=['concentration',
'moa', 'compound', 'Replicate']
):
super().__init__(labels_path=labels_path,
output_dir=output_dir,
include_groups=include_groups,
include_header=include_header,
class_column_header=class_column_header,
excluded_groups=excluded_groups,
excluded_groups_headers=excluded_groups_headers,
exclude_images_path=exclude_images_path,
intact_group_header=intact_group_header,
unique_sample_headers=unique_sample_headers,
image_number_heading=image_number_heading,
k_folds=k_folds,
divide_on_header=divide_on_header,
valid_fraction=valid_fraction,
non_unique_divider=non_unique_divider)
self.leave_one_out = leave_one_out
self.make_unique_validation = make_unique_validation
def main(self):
print("Started making divisions for runs for BBBC021.")
if self.leave_one_out:
if self.make_unique_validation:
self.make_leave_one_out()
else:
self.make_leave_one_out_train_test()
else:
if self.make_unique_validation:
self.make_k_folds()
else:
self.make_k_folds_train_test()
print("Finished. Find output in: " + self.output_dir)
if __name__ == "__main__":
MakeKFoldsTVTBBBC021().main()