Examples of maxValueIndex()


Examples of org.apache.mahout.math.DenseVector.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.DenseVector.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.DenseVector.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.DenseVector.maxValueIndex()

            metrics.AvgLogLikelihood = 0;
          }
         
          Vector p = new DenseVector(this.num_categories);
          this.polr.classifyFull(p, v);
          int estimated = p.maxValueIndex();
          int correct = (estimated == actual ? 1 : 0);
          metrics.AvgCorrect = metrics.AvgCorrect
              + (correct - metrics.AvgCorrect) / mu;
          this.polr.train(actual, v);
         
View Full Code Here

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

      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

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()

  @Override
  public Vector classify(Vector instance) {
    Vector result = classifyNoLink(instance);
    // Find the max value's index.
    int max = result.maxValueIndex();
    result.assign(0);
    result.setQuick(max, 1.0);
    return result.viewPart(1, result.size() - 1);
  }
View Full Code Here

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

    throws IOException, InterruptedException {
    if (!clusterModels.isEmpty()) {
      Vector pdfPerCluster = clusterClassifier.classify(vw.get());
      if (shouldClassify(pdfPerCluster)) {
        if (emitMostLikely) {
          int maxValueIndex = pdfPerCluster.maxValueIndex();
          write(vw, context, maxValueIndex, 1.0);
        } else {
          writeAllAboveThreshold(vw, context, pdfPerCluster);
        }
      }
View Full Code Here

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

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