def test_bow(self):
        model = Model('bow', self.gmm)
        model.compute_kernels([self.tr_fn], [self.te_fn])
        Kxx, Kyx = model.get_kernels()

        evaluation = Evaluation(self.dataset.DATASET)
        score = evaluation.fit(Kxx, self.cx).score(Kyx, self.cy)
        assert_allclose(score, self.expected_scores['bow'], rtol=1e-4)
Example #2
0
    def test_bow(self):
        model = Model('bow', self.gmm)
        model.compute_kernels([self.tr_fn], [self.te_fn])
        Kxx, Kyx = model.get_kernels()

        evaluation = Evaluation(self.dataset.DATASET)
        score = evaluation.fit(Kxx, self.cx).score(Kyx, self.cy)
        assert_allclose(score, self.expected_scores['bow'], rtol=1e-4)
Example #3
0
def evaluate_given_dataset(dataset, **kwargs):
    model_type = kwargs.get('model_type', 'fv')

    sstats_folder = dataset.SSTATS_DIR

    tr_fn = os.path.join(sstats_folder, 'train.dat')
    tr_labels_fn = os.path.join(sstats_folder, 'labels_train.info')

    te_fn = os.path.join(sstats_folder, 'test.dat')
    te_labels_fn = os.path.join(sstats_folder, 'labels_test.info')

    gmm = load_gmm(dataset.GMM)

    tr_labels = pickle.load(open(tr_labels_fn, 'r'))
    te_labels = pickle.load(open(te_labels_fn, 'r'))

    model = Model(model_type, gmm)
    model.compute_kernels([tr_fn], [te_fn])
    Kxx, Kyx = model.get_kernels()

    evaluation = Evaluation(dataset.DATASET, **kwargs)
    print evaluation.fit(Kxx, tr_labels).score(Kyx, te_labels)
Example #4
0
def evaluate_given_dataset(dataset, **kwargs):
    model_type = kwargs.get('model_type', 'fv')

    sstats_folder = dataset.SSTATS_DIR

    tr_fn = os.path.join(sstats_folder, 'train.dat')
    tr_labels_fn = os.path.join(sstats_folder, 'labels_train.info')

    te_fn = os.path.join(sstats_folder, 'test.dat')
    te_labels_fn = os.path.join(sstats_folder, 'labels_test.info')

    gmm = load_gmm(dataset.GMM)

    tr_labels = pickle.load(open(tr_labels_fn, 'r'))
    te_labels = pickle.load(open(te_labels_fn, 'r'))

    model = Model(model_type, gmm)
    model.compute_kernels([tr_fn], [te_fn])
    Kxx, Kyx = model.get_kernels()

    evaluation = Evaluation(dataset.DATASET, **kwargs)
    print evaluation.fit(Kxx, tr_labels).score(Kyx, te_labels)