示例#1
0
 def test_transform(self):
     for elements, stack in self.stacks:
         np.random.seed(42)
         Xt_stack, _, _ = stack.fit(self.X, self.y).transform(self.X)
         np.random.seed(42)
         Xt_elements = None
         for i, element in enumerate(elements):
             Xt_element, _, _ = element.fit(self.X,
                                            self.y).transform(self.X)
             Xt_elements = PhotonDataHelper.stack_data_horizontally(
                 Xt_elements, Xt_element)
         np.testing.assert_array_equal(Xt_stack, Xt_elements)
示例#2
0
 def inverse_transform(self, X, y=None, **kwargs):
     new_X = None
     for i in range(X.shape[1]):
         feature = X[:, i]
         transformer = self.encoder_list[i]
         if transformer is not None:
             feature = np.reshape(feature, (-1, 1))
             trans_X = transformer.inverse_transform(feature)
         else:
             trans_X = feature
         new_X = PhotonDataHelper.stack_data_horizontally(new_X, trans_X)
     return new_X
示例#3
0
 def test_predict(self):
     for elements, stack in [
         ([self.svc, self.tree], self.estimator_stack),
         ([self.estimator_branch_1,
           self.estimator_branch_2], self.estimator_branch_stack)
     ]:
         np.random.seed(42)
         stack = stack.fit(self.X, self.y)
         yt_stack = stack.predict(self.X)
         np.random.seed(42)
         Xt_elements = None
         for i, element in enumerate(elements):
             Xt_element = element.fit(self.X, self.y).predict(self.X)
             Xt_elements = PhotonDataHelper.stack_data_horizontally(
                 Xt_elements, Xt_element)
         np.testing.assert_array_equal(yt_stack, Xt_elements)