Ejemplo n.º 1
0
    def test_normalizacao(self):

        # dados de entrada
        v1 = [1, 0.8, 0.2, 0.5]
        v2 = [1, 0.7, 0.1, 0.6]
        v3 = [0, 0.2, 0.8, 0.2]

        # resultados esperados
        nv1 = [0.719815751, 0.575852601, 0.14396315, 0.359907875]
        nv2 = [0.733235575, 0.513264902, 0.073323557, 0.439941345]
        nv3 = [0, 0.235702261, 0.942809042, 0.235702261]

        for e, v in zip(nv1, algebra.normaliza(v1)):
            self.assertAlmostEqual(e, v, 5)
        for e, v in zip(nv2, algebra.normaliza(v2)):
            self.assertAlmostEqual(e, v, 5)
        for e, v in zip(nv3, algebra.normaliza(v3)):
            self.assertAlmostEqual(e, v, 5)
Ejemplo n.º 2
0
    def test_normalizacao(self):

        # Input:
        vector_test1 = [1, 0.8, 0.2, 0.5]
        vector_test2 = [1, 0.7, 0.1, 0.6]
        vector_teste3 = [0, 0.2, 0.8, 0.2]

        # Expected results:
        nv1 = [0.719815751, 0.575852601, 0.14396315, 0.359907875]
        nv2 = [0.733235575, 0.513264902, 0.073323557, 0.439941345]
        nv3 = [0, 0.235702261, 0.942809042, 0.235702261]

        for e, v in zip(nv1, algebra.normaliza(vector_test1)):
            self.assertAlmostEqual(e, v, 5)
        for e, v in zip(nv2, algebra.normaliza(vector_test2)):
            self.assertAlmostEqual(e, v, 5)
        for e, v in zip(nv3, algebra.normaliza(vector_teste3)):
            self.assertAlmostEqual(e, v, 5)
Ejemplo n.º 3
0
  def test_normalizacao(self):

    # Input:
    vector_test1 = [1, 0.8, 0.2, 0.5]
    vector_test2 = [1, 0.7, 0.1, 0.6]
    vector_teste3 = [0, 0.2, 0.8, 0.2]

    # Expected results:
    nv1 = [0.719815751, 0.575852601, 0.14396315, 0.359907875]
    nv2 = [0.733235575, 0.513264902, 0.073323557, 0.439941345]
    nv3 = [0, 0.235702261, 0.942809042, 0.235702261]

    for e, v in zip(nv1, algebra.normaliza(vector_test1)):
      self.assertAlmostEqual(e, v, 5)
    for e, v in zip(nv2, algebra.normaliza(vector_test2)):
      self.assertAlmostEqual(e, v, 5)
    for e, v in zip(nv3, algebra.normaliza(vector_teste3)):
      self.assertAlmostEqual(e, v, 5)
Ejemplo n.º 4
0
  def test_normalizacao(self):

    # dados de entrada
    v1 = [1, 0.8, 0.2, 0.5]
    v2 = [1, 0.7, 0.1, 0.6]
    v3 = [0, 0.2, 0.8, 0.2]

    # resultados esperados
    nv1 = [0.719815751, 0.575852601, 0.14396315, 0.359907875]
    nv2 = [0.733235575, 0.513264902, 0.073323557, 0.439941345]
    nv3 = [0, 0.235702261, 0.942809042, 0.235702261]

    for e, v in zip(nv1, algebra.normaliza(v1)):
      self.assertAlmostEqual(e, v, 5)
    for e, v in zip(nv2, algebra.normaliza(v2)):
      self.assertAlmostEqual(e, v, 5)
    for e, v in zip(nv3, algebra.normaliza(v3)):
      self.assertAlmostEqual(e, v, 5)
Ejemplo n.º 5
0
def semelhanca_vetores(vetor1, vetor2):
  nv1 = algebra.normaliza(vetor1)
  nv2 = algebra.normaliza(vetor2)
  return algebra.prod_escalar(nv1, nv2)
Ejemplo n.º 6
0
def semelhanca_vetores(vetor1, vetor2):
    nv1 = algebra.normaliza(vetor1)
    nv2 = algebra.normaliza(vetor2)
    return algebra.prod_escalar(nv1, nv2)