Package org.apache.mahout.math

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


      String ng = next.getFirst().toString();

      int actual = asfDictionary.intern(ng);
      Vector result = classifier.classifyFull(next.getSecond().get());
      int cat = result.maxValueIndex();
      double score = result.maxValue();
      double ll = classifier.logLikelihood(actual, next.getSecond().get());
      ClassifierResult cr = new ClassifierResult(asfDictionary.values().get(cat), score, ll);
      ra.addInstance(asfDictionary.values().get(actual), cr);

    }
View Full Code Here


    }
    enc.addToVector(builder.toString(), v1);
    enc.flush(1, v1);
    //System.out.println(v1);
    assertEquals(2000.0, v1.norm(1), 0);
    assertEquals(19.0, v1.maxValue(), 0);
  }
}
View Full Code Here

      int actual = newsGroups.intern(ng);
      NewsgroupHelper helper = new NewsgroupHelper();
      Vector input = helper.encodeFeatureVector(file, actual, 0, overallCounts); //no leak type ensures this is a normal vector
      Vector result = classifier.classifyFull(input);
      int cat = result.maxValueIndex();
      double score = result.maxValue();
      double ll = classifier.logLikelihood(actual, input);
      ClassifierResult cr = new ClassifierResult(newsGroups.values().get(cat), score, ll);
      ra.addInstance(newsGroups.values().get(actual), cr);

    }
View Full Code Here

      csv.processLine(line, v, false);
      Vector scores = learner.classifyFull(v);
      results.clear();
      if (maxScoreOnly) {
        results.put(csv.getTargetLabel(scores.maxValueIndex()),
            scores.maxValue());
      } else {
        for (int i = 0; i < scores.size(); i++) {
          results.put(csv.getTargetLabel(i), scores.get(i));
        }
      }
View Full Code Here

    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));
    enc.setWordEncoder(w);
View Full Code Here

    enc.flush(1, v1);

    //should be the same as text test above, since we are splitting on whitespace
    // should set 6 distinct locations to 1
    assertEquals(6.0, v1.norm(1), 0);
    assertEquals(1.0, v1.maxValue(), 0);

    v1 = new DenseVector(200);
    enc.addToVector("", v1);
    enc.flush(1, v1);
    assertEquals(0.0, v1.norm(1), 0);
View Full Code Here

    v1 = new DenseVector(200);
    enc.addToVector("", v1);
    enc.flush(1, v1);
    assertEquals(0.0, v1.norm(1), 0);
    assertEquals(0.0, v1.maxValue(), 0);

    v1 = new DenseVector(200);
    StringBuilder builder = new StringBuilder(5000);
    for (int i = 0; i < 1000; i++) {//lucene's internal buffer length request is 4096, so let's make sure we can handle larger size
      builder.append("token_").append(i).append(' ');
View Full Code Here

        csv.processLine(line, v, false);
        Vector scores = learner.classifyFull(v);
        results.clear();
        if (maxScoreOnly) {
          results.put(csv.getTargetLabel(scores.maxValueIndex()),
            scores.maxValue());
        } else {
          for (int i = 0; i < scores.size(); i++) {
            results.put(csv.getTargetLabel(i), scores.get(i));
          }
        }
View Full Code Here

      int curX = (col % patchesPerRow ) * (patchWidth + patchBorder );
      int curY = col / patchesPerRow * ( patchHeight + patchBorder );
     
      Vector column = data.viewColumn( col );
     
      double col_max = column.maxValue();
      double col_min = column.minValue();
     
      // now reshape the column into the shape of the filter patch
     
     
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.