Esempio n. 1
0
 def test_fit_features(self):
     trans = Shell(input_type="filename")
     feats = trans.fit_transform(ALL)
     a = AtomKernel()
     values = list(zip(feats, ALL_NUMS))
     a.fit(values)
     self.assertEqual(ALL_NUMS, list(a._numbers))
     self.assertEqual(list(ALL_FEATURES), list(a._features))
Esempio n. 2
0
 def test_transform_transformer(self):
     trans = Shell(input_type="filename")
     a = AtomKernel(transformer=trans)
     a.fit(ALL)
     res = a.transform(ALL)
     try:
         numpy.testing.assert_array_almost_equal(RBF_KERNEL, res)
     except AssertionError as e:
         self.fail(e)
Esempio n. 3
0
 def test_laplace_kernel(self):
     # Set depth=2 so the comparison is not trivial
     trans = Shell(input_type="filename", depth=2)
     a = AtomKernel(transformer=trans, kernel="laplace", gamma=1.)
     a.fit(ALL)
     res = a.transform(ALL)
     try:
         numpy.testing.assert_array_almost_equal(LAPLACE_KERNEL, res)
     except AssertionError as e:
         self.fail(e)
Esempio n. 4
0
 def test_transform_features(self):
     trans = Shell(input_type="filename")
     feats = trans.fit_transform(ALL)
     a = AtomKernel()
     values = list(zip(feats, ALL_NUMS))
     a.fit(values)
     res = a.transform(values)
     try:
         numpy.testing.assert_array_almost_equal(RBF_KERNEL, res)
     except AssertionError as e:
         self.fail(e)
Esempio n. 5
0
 def test_custom_kernel(self):
     # Set depth=2 so the comparison is not trivial
     trans = Shell(input_type="filename", depth=2)
     # Simple linear kernel
     a = AtomKernel(transformer=trans,
                    kernel=lambda x, y: numpy.dot(x, numpy.transpose(y)))
     a.fit(ALL)
     res = a.transform(ALL)
     try:
         numpy.testing.assert_array_almost_equal(LINEAR_KERNEL, res)
     except AssertionError as e:
         self.fail(e)
Esempio n. 6
0
 def test_fit_transformer(self):
     trans = Shell(input_type="filename")
     a = AtomKernel(transformer=trans)
     a.fit(ALL)
     self.assertEqual(ALL_NUMS, [x.tolist() for x in a._numbers])
     self.assertEqual(list(ALL_FEATURES), list(a._features))