Examples of maxValueIndex()


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

      lossSum = 0;
    }
    Vector result = classifyNoLink(instance);
    double myScore = result.get(actual);
    // Find the highest score that is not actual.
    int otherIndex = result.maxValueIndex();
    double otherValue = result.get(otherIndex);
    if (otherIndex == actual) {
      result.setQuick(otherIndex, Double.NEGATIVE_INFINITY);
      otherIndex = result.maxValueIndex();
      otherValue = result.get(otherIndex);
View Full Code Here

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

    // Find the highest score that is not actual.
    int otherIndex = result.maxValueIndex();
    double otherValue = result.get(otherIndex);
    if (otherIndex == actual) {
      result.setQuick(otherIndex, Double.NEGATIVE_INFINITY);
      otherIndex = result.maxValueIndex();
      otherValue = result.get(otherIndex);
    }
    double loss = 1.0 - myScore + otherValue;
    lossCount += 1;
    if (loss >= 0) {
View Full Code Here

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

      int actual = newsGroups.intern(ng);
      NewsgroupHelper helper = new NewsgroupHelper();
      //no leak type ensures this is a normal vector
      Vector input = helper.encodeFeatureVector(file, actual, 0, overallCounts);
      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

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

      Vector v = new SequentialAccessSparseVector(lmp.getNumFeatures());
      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

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

      Pair<Text, VectorWritable> next = iter.next();
      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

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

    assertEquals(0, t);
    // should have 9 values set
    assertEquals(9.0, v.norm(0), 0);
    // all should be = 1 except for the 3.1
    assertEquals(3.1, v.maxValue(), 0);
    v.set(v.maxValueIndex(), 0);
    assertEquals(8.0, v.norm(0), 0);
    assertEquals(8.0, v.norm(1), 0);
    assertEquals(1.0, v.maxValue(), 0);

    v.assign(0);
View Full Code Here

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

    // should have 9 values set
    assertEquals(9.0, v.norm(0), 0);
    // all should be = 1 except for the 3.1
    assertEquals(5.3, v.maxValue(), 0);
    v.set(v.maxValueIndex(), 0);
    assertEquals(8.0, v.norm(0), 0);
    assertEquals(10.339850002884626, v.norm(1), 1.0e-6);
    assertEquals(1.5849625007211563, v.maxValue(), 1.0e-6);

    v.assign(0);
View Full Code Here

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

    // should have 9 values set
    assertEquals(9.0, v.norm(0), 0);
    // all should be = 1 except for the 3.1
    assertEquals(5.3, v.maxValue(), 0);
    v.set(v.maxValueIndex(), 0);
    assertEquals(8.0, v.norm(0), 0);
    assertEquals(10.339850002884626, v.norm(1), 1.0e-6);
    assertEquals(1.5849625007211563, v.maxValue(), 1.0e-6);
  }
View Full Code Here

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

      if (k == trackingKey % models.size()) {
        Vector v = model.classifyFull(instance);
        double score = Math.max(v.get(actual), MIN_SCORE);
        logLikelihood += (Math.log(score) - logLikelihood) / Math.min(record, windowSize);

        int correct = v.maxValueIndex() == actual ? 1 : 0;
        percentCorrect += (correct - percentCorrect) / Math.min(record, windowSize);
        if (numCategories() == 2) {
          auc.addSample(actual, groupKey, v.get(1));
        }
      } else {
View Full Code Here

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

      List<WeightedPropertyVectorWritable> wpvList = collector.getValue(k);
      assertTrue("empty cluster!", !wpvList.isEmpty());
      if (wpvList.get(0).getVector().get(0) <= 2.0) {
        for (WeightedPropertyVectorWritable wv : wpvList) {
          Vector v = wv.getVector();
          int idx = v.maxValueIndex();
          assertTrue("bad cluster!", v.get(idx) <= 2.0);
        }
        assertEquals("Wrong size cluster", 4, wpvList.size());
      } else {
        for (WeightedPropertyVectorWritable wv : wpvList) {
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.