Exemplo n.º 1
0
 def test_zigzag1d(self):
     a = fred.Curve(np.array([0.0, 1.0, 0.0, 1.0]))
     b = fred.Curve(np.array([0.0, 0.75, 0.25, 1.0]))
     c = fred.Curve(np.array([0.0, 1.0]))
     self.assertEqual(fred.continuous_frechet(a, b).value, 0.25)
     self.assertEqual(fred.continuous_frechet(a, c).value, 0.5)
Exemplo n.º 2
0
 def test_longsegment(self):
     a = fred.Curve(np.array([0.0, 500.0e3, 1.0e6]))
     b = fred.Curve(np.array([0.0, 1.0e6]))
     self.assertEqual(fred.discrete_frechet(a, b).value, 500000.0)
Exemplo n.º 3
0
import Fred.backend as fred
import Fred
import numpy as np

sep = 1000

p1 = np.array([[0, 0], [sep / 2, 0], [0, 0.1], [sep / 4, 0.1], [sep / 2, 0.1]])
p2 = np.array([[0, -0.1], [sep, -0.1], [sep / 2, 0], [sep, 0], [sep / 2, 0.1]])

curves = fred.Curves()

curves.add(fred.Curve(p1, "Input Curve {}".format(1)))
curves.add(fred.Curve(p2, "Input Curve {}".format(2)))

clustering = fred.two_two_dtw_one_two_median(curves)
clustering_e = fred.two_two_dtw_one_two_median_exact(curves)

print(clustering.value / clustering_e.value)

Fred.plot_curve(curves, clustering, clustering_e)
Exemplo n.º 4
0
import Fred.backend as fred
import Fred
import numpy as np

c1 = fred.Curve(
    np.array([[0.0, -1.0], [-1.0, 3.0], [1.0, 0.1], [6.1, 0.1], [6.2, 0.1],
              [6.3, 0.1], [6.4, 0.1], [6.5, 0.1], [7.0, 0.1], [8.0, 0.1],
              [8.3, 0.1], [8.4, 0.1], [8.5, 0.1], [8.6, 0.1], [8.7, 0.1],
              [8.8, 0.1], [8.9, 0.1], [10, -1.0]]), "Eingabe 1")
c2 = fred.Curve(
    np.array([[0.0, -1.0], [1.0, -0.1], [1.1, -0.1], [1.2, -0.1], [1.3, -0.1],
              [1.4, -0.1], [1.5, -0.1], [1.6, -0.1], [2.0, -0.1], [3.0, -0.1],
              [4.0, -0.1], [5.0, -0.1], [6.0, -0.1], [7.0, -0.1], [8.0, -0.1],
              [11.0, 3.0], [10.0, -1.0]]), "Eingabe 2")

curves = fred.Curves()
curves.add(c1)
curves.add(c2)

clustering = fred.two_two_dtw_one_two_median(curves)
clustering_e = fred.two_two_dtw_one_two_median_exact(curves)

print(clustering.value / clustering_e.value)

Fred.plot_curve(curves, clustering, clustering_e)
Exemplo n.º 5
0
    for j in range(clusteroutliers):
        kk = int(np.random.rand() * clusternumber)
        while kk == k:
            kk = int(np.random.rand() * clusternumber)
        k = kk
        randomdirection = np.random.normal(0, 1, (1, 2)).flatten()
        randomdirection /= np.linalg.norm(randomdirection)
        c1[k] += outlierradius * randomdirection

    k = None

    for j in range(clusteroutliers):
        kk = int(np.random.rand() * clusternumber)
        while kk == k:
            kk = int(np.random.rand() * clusternumber)
        k = kk
        randomdirection = np.random.normal(0, 1, (1, 2)).flatten()
        randomdirection /= np.linalg.norm(randomdirection)
        c2[k] += outlierradius * randomdirection

    curves.add(
        fred.Curve(np.concatenate([c1, inb, c2]),
                   "Input Curve {}".format(i + 1)))

clustering = fred.two_two_dtw_one_two_median(curves)
clustering_e = fred.two_two_dtw_one_two_median_exact(curves)

print(clustering.value / clustering_e.value)

Fred.plot_curve(curves, clustering, clustering_e)