class ClassifierConfig(): def __init__(self, dataset, L, numfolds=4): self.d = Dataset(dataset) self.e = Extractor() self.dense_codebook = self.e.get_codebook(self.d, 'dsift') self.sparse_codebook = self.e.get_codebook(self.d, 'sift') self.L = L self.numfolds = numfolds def kfold(self): train_idx, val_idx = KFold(len(len(self.d.images), self.numfolds)) self.d.create_folds(self.numfolds)
def test_kfold(self): """ 'sizes' here are empirical values over the trainval set. """ d = Dataset('full_pascal_trainval') numfolds = 4 d.create_folds(numfolds) cls = 'dog' sizes = [314, 308, 321, 320] for i in range(len(d.folds)): d.next_folds() pos = d.get_pos_samples_for_fold_class(cls) neg = d.get_neg_samples_for_fold_class(cls, pos.shape[0]) assert (pos.shape[0] == sizes[i]) assert (neg.shape[0] == sizes[i])
def test_kfold(self): """ 'sizes' here are empirical values over the trainval set. """ d = Dataset('full_pascal_trainval') numfolds = 4 d.create_folds(numfolds) cls = 'dog' sizes = [314, 308, 321, 320] for i in range(len(d.folds)): d.next_folds() pos = d.get_pos_samples_for_fold_class(cls) neg = d.get_neg_samples_for_fold_class(cls, pos.shape[0]) assert(pos.shape[0] == sizes[i]) assert(neg.shape[0] == sizes[i])