Examples of maxValueIndex()


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

        }
      }
      Vector pdfPerCluster = clusterClassifier.classify(vector);
      if (shouldClassify(pdfPerCluster)) {
        if (emitMostLikely) {
          int maxValueIndex = pdfPerCluster.maxValueIndex();
          write(new VectorWritable(vector), context, maxValueIndex, 1.0);
        } else {
          writeAllAboveThreshold(new VectorWritable(vector), context, pdfPerCluster);
        }
      }
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);
        } else {
          writeAllAboveThreshold(vw, context, pdfPerCluster);
        }
      }
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()

      List<WeightedVectorWritable> wvList = collector.getValue(k);
      assertTrue("empty cluster!", wvList.size() != 0);
      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

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

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

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

      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

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

          for (int i = parameters.columnStart, j = 0; i < Math.min(parameters.columnEnd + 1, tokens.length); ++i, ++j) {
            features[j] = Double.parseDouble(tokens[i]);
          }
          Vector featureVec = new DenseVector(features);
          Vector res = mlp.getOutput(featureVec);
          int mostProbablyLabelIndex = res.maxValueIndex();
          writer.write(String.valueOf(mostProbablyLabelIndex));
        }
        mlp.close();
        log.info("Labeling finished.");
      } finally {
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.