Package org.apache.mahout.common

Examples of org.apache.mahout.common.StringTuple.stringAt()


    for (FileStatus fileStatus : outputFiles) {
      Path path = fileStatus.getPath();
      SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
      // the key is either _label_ or label,feature
      while (reader.next(key, value)) {
        if (key.stringAt(0).equals(BayesConstants.LABEL_SUM)) { // Sum of counts
          // of labels
          labelSum.put(key.stringAt(1), value.get());
        }
       
      }
View Full Code Here


      SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
      // the key is either _label_ or label,feature
      while (reader.next(key, value)) {
        if (key.stringAt(0).equals(BayesConstants.LABEL_SUM)) { // Sum of counts
          // of labels
          labelSum.put(key.stringAt(1), value.get());
        }
       
      }
    }
   
View Full Code Here

      Path path = fileStatus.getPath();
      SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
      // the key is either _label_ or label,feature
      while (reader.next(key, value)) {
        // Count of Documents in a Label
        if (key.stringAt(0).equals(BayesConstants.LABEL_COUNT)) {
          labelDocumentCounts.put(key.stringAt(1), value.get());
        }
       
      }
    }
View Full Code Here

      SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
      // the key is either _label_ or label,feature
      while (reader.next(key, value)) {
        // Count of Documents in a Label
        if (key.stringAt(0).equals(BayesConstants.LABEL_COUNT)) {
          labelDocumentCounts.put(key.stringAt(1), value.get());
        }
       
      }
    }
   
View Full Code Here

      Path path = fileStatus.getPath();
      SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
      while (reader.next(key, value)) {
        if (weightSum.size() > 1) {
          throw new IOException("Incorrect Sum File");
        } else if (key.stringAt(0).equals(BayesConstants.TOTAL_SUM)) {
          weightSum.put(BayesConstants.TOTAL_SUM, value.get());
        }
       
      }
    }
View Full Code Here

      SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
      while (reader.next(key, value)) {
        if (weightSum.size() > 1) {
          throw new IOException("Incorrect vocabCount File");
        }
        if (key.stringAt(0).equals(BayesConstants.FEATURE_SET_SIZE)) {
          weightSum.put(BayesConstants.FEATURE_SET_SIZE, value.get());
        }
       
      }
    }
View Full Code Here

  protected String generateFileNameForKeyValue(WritableComparable<?> k,
      Writable v, String name) {
    StringTuple key = (StringTuple) k;

    if (key.length() == 1
        && key.stringAt(0).equals(BayesConstants.FEATURE_SET_SIZE))
      return "trainer-vocabCount/" + name;
    else
      return "trainer-tfIdf/" + name;
  }
View Full Code Here

   
    for (FileStatus fileStatus : outputFiles) {
      Path path = fileStatus.getPath();
      SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
      while (reader.next(key, value)) {       
        String correctLabel = key.stringAt(1);
        String classifiedLabel = key.stringAt(2);
        Map<String, Integer> rowMatrix = confusionMatrix.get(correctLabel);
        if(rowMatrix == null)
          rowMatrix = new HashMap<String, Integer>();       
        Integer count = Double.valueOf(value.get()).intValue();
View Full Code Here

    for (FileStatus fileStatus : outputFiles) {
      Path path = fileStatus.getPath();
      SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
      while (reader.next(key, value)) {       
        String correctLabel = key.stringAt(1);
        String classifiedLabel = key.stringAt(2);
        Map<String, Integer> rowMatrix = confusionMatrix.get(correctLabel);
        if(rowMatrix == null)
          rowMatrix = new HashMap<String, Integer>();       
        Integer count = Double.valueOf(value.get()).intValue();
        rowMatrix.put(classifiedLabel, count);
View Full Code Here

  @Override
  protected String generateFileNameForKeyValue(WritableComparable<?> k, Writable v,
                                               String name) {
    StringTuple key = (StringTuple) k;

    if(key.length() == 1 && key.stringAt(0).equals(BayesConstants.TOTAL_SUM))
    {
      return "Sigma_kSigma_j/" + name;
    }
    else{
      if(key.stringAt(0).equals(BayesConstants.FEATURE_SUM))
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.