Examples of norm()


Examples of org.apache.mahout.math.Vector.norm()

    }
    for(Map.Entry<Integer, Vector> entry : mMap.entrySet()) {
      Integer key = entry.getKey();
      Vector value = entry.getValue();
      if(value == null || mttMap.get(key) == null) {
        assertTrue(value == null || value.norm(2) == 0);
        assertTrue(mttMap.get(key) == null || mttMap.get(key).norm(2) == 0);
      } else {
        assertTrue(
            value.getDistanceSquared(mttMap.get(key)) < errorTolerance);
      }
View Full Code Here

Examples of org.apache.mahout.math.Vector.norm()

    FeatureVectorEncoder enc = new ContinuousValueEncoder("foo");
    Vector v1 = new DenseVector(20);
    enc.addToVector("-123", v1);
    assertEquals(-123, v1.minValue(), 0);
    assertEquals(0, v1.maxValue(), 0);
    assertEquals(123, v1.norm(1), 0);

    v1 = new DenseVector(20);
    enc.addToVector("123", v1);
    assertEquals(123, v1.maxValue(), 0);
    assertEquals(0, v1.minValue(), 0);
View Full Code Here

Examples of org.apache.mahout.math.Vector.norm()

    v1 = new DenseVector(20);
    enc.addToVector("123", v1);
    assertEquals(123, v1.maxValue(), 0);
    assertEquals(0, v1.minValue(), 0);
    assertEquals(123, v1.norm(1), 0);

    Vector v2 = new DenseVector(20);
    enc.setProbes(2);
    enc.addToVector("123", v2);
    assertEquals(123, v2.maxValue(), 0);
View Full Code Here

Examples of org.apache.mahout.math.Vector.norm()

    Vector v2 = new DenseVector(20);
    enc.setProbes(2);
    enc.addToVector("123", v2);
    assertEquals(123, v2.maxValue(), 0);
    assertEquals(2 * 123, v2.norm(1), 0);

    v1 = v2.minus(v1);
    assertEquals(123, v1.maxValue(), 0);
    assertEquals(123, v1.norm(1), 0);

View Full Code Here

Examples of org.apache.mahout.math.Vector.norm()

    TextValueEncoder enc = new TextValueEncoder("text");
    Vector v1 = new DenseVector(200);
    enc.addToVector("test1 and more", v1);
    enc.flush(1, v1);
    // should set 6 distinct locations to 1
    assertEquals(6.0, v1.norm(1), 0);
    assertEquals(1.0, v1.maxValue(), 0);

    // now some fancy weighting
    StaticWordValueEncoder w = new StaticWordValueEncoder("text");
    w.setDictionary(ImmutableMap.<String, Double>of("word1", 3.0, "word2", 1.5));
View Full Code Here

Examples of org.apache.mahout.math.Vector.norm()

    InteractionValueEncoder enc = new InteractionValueEncoder("interactions", wv, cv);
    Vector v1 = new DenseVector(200);
    enc.addInteractionToVector("a","1.0",1.0, v1);
    int k = enc.getProbes();
    // should set k distinct locations to 1
    assertEquals((float) k, v1.norm(1), 0);
    assertEquals(1.0, v1.maxValue(), 0);

    // adding same interaction again should increment weights
    enc.addInteractionToVector("a","1.0",1.0,v1);
    assertEquals((float) k*2, v1.norm(1), 0);
View Full Code Here

Examples of org.apache.mahout.math.Vector.norm()

    assertEquals((float) k, v1.norm(1), 0);
    assertEquals(1.0, v1.maxValue(), 0);

    // adding same interaction again should increment weights
    enc.addInteractionToVector("a","1.0",1.0,v1);
    assertEquals((float) k*2, v1.norm(1), 0);
    assertEquals(2.0, v1.maxValue(), 0);

    Vector v2 = new DenseVector(20000);
    enc.addInteractionToVector("a","1.0",1.0,v2);
    wv.addToVector("a", v2);
View Full Code Here

Examples of org.apache.mahout.math.Vector.norm()

    enc.addInteractionToVector("a","1.0",1.0,v2);
    wv.addToVector("a", v2);
    cv.addToVector("1.0", v2);
    k = enc.getProbes();
    //this assumes no hash collision
    assertEquals((float) (k + wv.getProbes()+cv.getProbes()), v2.norm(1), 1.0e-3);
  }

  @Test
  public void testAddToVectorUsesProductOfWeights(){
    WordValueEncoder wv = new StaticWordValueEncoder("word");
View Full Code Here

Examples of org.apache.mahout.math.Vector.norm()

    InteractionValueEncoder enc = new InteractionValueEncoder("interactions", wv, cv);
    Vector v1 = new DenseVector(200);
    enc.addInteractionToVector("a","0.9",0.5, v1);
    int k = enc.getProbes();
    // should set k distinct locations to 0.9*0.5
    assertEquals((float) k*0.5*0.9, v1.norm(1), 0);
    assertEquals(0.5*0.9, v1.maxValue(), 0);
  }

  @Test
  public void testAddToVectorWithTextValueEncoder(){
View Full Code Here

Examples of org.apache.mahout.math.Vector.norm()

    InteractionValueEncoder enc = new InteractionValueEncoder("interactions", wv, tv);
    Vector v1 = new DenseVector(200);
    enc.addInteractionToVector("a","some text here",1.0, v1);
    int k = enc.getProbes();
    // should interact "a" with each of "some","text" and "here"
    assertEquals((float) k*3, v1.norm(1), 0);
  }

}
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.