Exemple #1
0
    def test_mds_params(self):
        np.random.seed(14)
        X = np.random.random((10, 2))
        y = np.random.randint(0, 2, 10)
        X_cand = np.random.random((15, 2))

        alce = ALCE(self.classes,
                    self.regressor,
                    self.cost_matrix,
                    random_state=14,
                    mds_params={
                        'n_jobs': 1,
                        'verbose': 2
                    })
        cand1 = alce.query(X_cand, X, y)
        alce = ALCE(self.classes,
                    self.regressor,
                    self.cost_matrix,
                    random_state=14,
                    mds_params={'n_jobs': 2})
        cand2 = alce.query(X_cand, X, y)
        np.testing.assert_array_equal(cand1, cand2)

        alce = ALCE(self.classes,
                    self.regressor,
                    self.cost_matrix,
                    mds_params={'dissimilarity': 'wrong'})
        self.assertRaises(ValueError, alce.query, X_cand, X, y)

        alce = ALCE(base_regressor=self.regressor,
                    classes=[0, 1],
                    mds_params={'dissimilarity': 'precomputed'})
        query_indices = alce.query([[0], [100], [200]], [[0], [200]], [0, 1])
        np.testing.assert_array_equal(query_indices, [1])
Exemple #2
0
 def test_query_param_X(self):
     alce = ALCE(self.classes, self.regressor, self.cost_matrix)
     self.assertRaises(ValueError,
                       alce.query,
                       X_cand=self.X_cand,
                       X=np.ones((5, 3)),
                       y=self.y)
     _, result = alce.query(self.X_cand,
                            X=self.X,
                            y=[MISSING_LABEL] * len(self.X),
                            return_utilities=True)
     np.testing.assert_array_equal(result, np.ones((1, len(self.X_cand))))
Exemple #3
0
 def test_query(self):
     alce = ALCE(base_regressor=self.regressor, classes=[0, 1])
     query_indices = alce.query([[0], [100], [200]], [[0], [200]], [0, 1])
     np.testing.assert_array_equal(query_indices, [1])