MCPcopy Index your code
hub / github.com/InternScience/InternAgent / prepare_split

Method prepare_split

tasks/AutoTPPR/code/experiment.py:1030–1169  ·  view source on GitHub ↗

Prepare splits for training and testing Parameters ---------- split: str Type of split to use. Currently, we support 'simulation', 'simulation_single', 'combo_seen0', 'combo_seen1', 'combo_seen2', 'single', 'no_test', 'no_split',

(self, split = 'simulation', 
                      seed = 1, 
                      train_gene_set_size = 0.75,
                      combo_seen2_train_frac = 0.75,
                      combo_single_split_test_set_fraction = 0.1,
                      test_perts = None,
                      only_test_set_perts = False,
                      test_pert_genes = None,
                      split_dict_path=None)

Source from the content-addressed store, hash-verified

1028
1029
1030 def prepare_split(self, split = 'simulation',
1031 seed = 1,
1032 train_gene_set_size = 0.75,
1033 combo_seen2_train_frac = 0.75,
1034 combo_single_split_test_set_fraction = 0.1,
1035 test_perts = None,
1036 only_test_set_perts = False,
1037 test_pert_genes = None,
1038 split_dict_path=None):
1039
1040 """
1041 Prepare splits for training and testing
1042
1043 Parameters
1044 ----------
1045 split: str
1046 Type of split to use. Currently, we support 'simulation',
1047 'simulation_single', 'combo_seen0', 'combo_seen1', 'combo_seen2',
1048 'single', 'no_test', 'no_split', 'custom'
1049 seed: int
1050 Random seed
1051 train_gene_set_size: float
1052 Fraction of genes to use for training
1053 combo_seen2_train_frac: float
1054 Fraction of combo seen2 perturbations to use for training
1055 combo_single_split_test_set_fraction: float
1056 Fraction of combo single perturbations to use for testing
1057 test_perts: list
1058 List of perturbations to use for testing
1059 only_test_set_perts: bool
1060 If True, only use test set perturbations for testing
1061 test_pert_genes: list
1062 List of genes to use for testing
1063 split_dict_path: str
1064 Path to dictionary used for custom split. Sample format:
1065 {'train': [X, Y], 'val': [P, Q], 'test': [Z]}
1066
1067 Returns
1068 -------
1069 None
1070
1071 """
1072 available_splits = ['simulation', 'simulation_single', 'combo_seen0',
1073 'combo_seen1', 'combo_seen2', 'single', 'no_test',
1074 'no_split', 'custom']
1075 if split not in available_splits:
1076 raise ValueError('currently, we only support ' + ','.join(available_splits))
1077 self.split = split
1078 self.seed = seed
1079 self.subgroup = None
1080
1081 if split == 'custom':
1082 try:
1083 with open(split_dict_path, 'rb') as f:
1084 self.set2conditions = pickle.load(f)
1085 except:
1086 raise ValueError('Please set split_dict_path for custom split')
1087 return

Callers 1

mainFunction · 0.95

Calls 5

aggMethod · 0.80
print_sysFunction · 0.70
loadMethod · 0.45
dumpMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected