Beispiel #1
0
 def test_pairwise_error(self):
     self.assertEqual(util.pairwise_error(self.foo, self.foo), 0)
     self.assertEqual(
         util.pairwise_error(self.foo, self.foo, metric=distance.L1), 0)
Beispiel #2
0
 def test_pairwise_error(self):
   self.assertEqual(util.pairwise_error(self.foo, self.foo), 0)
   self.assertEqual(util.pairwise_error(self.foo, self.foo, metric=distance.L1), 0)
Beispiel #3
0
        ('cca_v2', lambda: CCAv2(X, Y, d)),
        ('linear manifold', lambda: ManifoldLinear(X, Y, corr, d, Wx, Wy)),
        ('ctw', lambda: ctw(X, Y, d)[1]),
        ('manifold warping',
         lambda: manifold_warping_linear(X, Y, d, Wx, Wy)[1]),
    )

    other_aligners = (
        ('dtw', lambda: (X, dtw(X, Y).warp(X))),
        ('nonlinear manifold aln',
         lambda: manifold_nonlinear(X, Y, corr, d, Wx, Wy)),
        ('nonlinear manifold warp',
         lambda: manifold_warping_nonlinear(X, Y, d, Wx, Wy)[1:]),
    )

    for name, aln in lin_aligners:
        pyplot.figure()
        with Timer(name):
            Xnew, Ynew = aln().project(X, Y)
        print ' sum sq. error =', pairwise_error(Xnew, Ynew, metric=SquaredL2)
        show_alignment(Xnew, Ynew, name)

    for name, aln in other_aligners:
        pyplot.figure()
        with Timer(name):
            Xnew, Ynew = aln()
        print ' sum sq. error =', pairwise_error(Xnew, Ynew, metric=SquaredL2)
        show_alignment(Xnew, Ynew, name)

    pyplot.show()
Beispiel #4
0
    ('ctw',              lambda: ctw(X,Y,d)[1]),
    ('manifold warping', lambda: manifold_warping_linear(X,Y,d,Wx,Wy)[1]),
  )

  other_aligners = (
    ('dtw', lambda: (X, dtw(X,Y).warp(X))),
    ('nonlinear manifold aln', lambda: manifold_nonlinear(X,Y,corr,d,Wx,Wy)),
    ('nonlinear manifold warp', lambda: manifold_warping_nonlinear(X,Y,d,Wx,Wy)[1:]),
  )

  pyplot.ion()

  for name, aln in lin_aligners:
    pyplot.figure()
    with Timer(name):
      Xnew,Ynew = aln().project(X, Y)
    print ' sum sq. error =', pairwise_error(Xnew, Ynew, metric=SquaredL2)
    show_alignment(Xnew,Ynew,name)
    pyplot.draw()

  for name, aln in other_aligners:
    pyplot.figure()
    with Timer(name):
      Xnew,Ynew = aln()
    print ' sum sq. error =', pairwise_error(Xnew, Ynew, metric=SquaredL2)
    show_alignment(Xnew, Ynew, name)
    pyplot.draw()

  pyplot.ioff()
  pyplot.show()