add train valid split
@@ -12,3 +12,15 @@ class BaseSplitter(object):
return train_inds, valid_inds, test_inds
else:
return dataset[train_inds], dataset[valid_inds], dataset[test_inds]
+
+ def train_valid_split(self, dataset, frac_train=.9, frac_valid=.1,
+ seed=None, return_index=True):
+ train_inds, valid_inds, test_inds = self.split(dataset,
+ frac_train=frac_train,
+ frac_valid=frac_valid,
+ frac_test=0)
+ assert len(test_inds) == 0
+ if return_index:
+ return train_inds, valid_inds
+ else:
+ return dataset[train_inds], dataset[valid_inds]
