Exemplo n.º 1
0
 def test_no_iso(self):
     """CKA is sensitive to column scaling"""
     X, Y = _get_multi()
     X0 = X[:, :2]
     X0p = X0 @ np.array([[1, 1], [10, 1]])
     c1 = cka(X0, Y)
     c2 = cka(X0p, Y)
     self.assertGreater(abs(c1 - c2), .001)
Exemplo n.º 2
0
 def test_rotation(self):
     """CKA is insensitive to rotations"""
     X, Y = _get_multi()
     X0 = X[:, :2]
     X0p = X0 @ np.array([[1, -1], [1, 1]]) / np.sqrt(2)
     c1 = cka(X0, Y)
     c2 = cka(X0p, Y)
     self.assertAlmostEqual(c1, c2)
Exemplo n.º 3
0
 def test_wide(self):
     """Smoke test."""
     X, Y = _get_wide()
     c1 = cka(X, Y)
Exemplo n.º 4
0
 def test_value(self):
     """Regression test: for this particular input, check that the value
     is the same as it always was."""
     X, Y = _get_multi()
     c1 = cka(X, Y)
     self.assertAlmostEqual(c1, 0.96577, places=4)
Exemplo n.º 5
0
 def test_isoscaling(self):
     """CKA is insensitive to scaling by a scalar"""
     X, Y = _get_multi()
     c1 = cka(X, Y)
     c2 = cka(2.0 * X, -1 * Y)
     self.assertAlmostEqual(c1, c2)
Exemplo n.º 6
0
 def test_corr(self):
     """The CKA of two vectors is the square of the correlation coefficient"""
     X, Y = _get_one()
     c1 = cka(X, Y)
     c2 = np.corrcoef(X.squeeze(), Y.squeeze())[0, 1]**2
     self.assertAlmostEqual(c1, c2)
Exemplo n.º 7
0
 def test_same(self):
     """The CKA of a matrix and itself is one"""
     X, _ = _get_one()
     self.assertAlmostEqual(cka(X, X), 1)
Exemplo n.º 8
0
 def test_wrong_dim(self):
     """It should throw an error if we have a different number of stimuli"""
     X = np.ones((8, 1))
     Y = np.ones((10, 1))
     cka(X, Y)