Package cc.mallet.types

Examples of cc.mallet.types.Labeling.numLocations()


    if (docLengthNormalization > 0)
      // Make the document have counts that sum to docLengthNormalization
      // I.e., if 20, it would be as if the document had 20 words.
      instanceWeight *= docLengthNormalization / oneNorm;
    assert (instanceWeight > 0 && !Double.isInfinite(instanceWeight));
    for (int lpos = 0; lpos < labeling.numLocations(); lpos++) {
      int li = labeling.indexAtLocation (lpos);
      double labelWeight = labeling.valueAtLocation (lpos);
      if (labelWeight == 0) continue;
      //System.out.println ("NaiveBayesTrainer me.increment "+ labelWeight * instanceWeight);
      me[li].increment (fv, labelWeight * instanceWeight);
 
View Full Code Here


      // Here is the difference between this code and the single label
      //  version: rather than only picking out the "best" index,
      //  loop over all label indices.
     
      assert(labeling.numLocations() == trainingSet.getTargetAlphabet().size());
      for (int pos = 0; pos < labeling.numLocations(); pos++){
        MatrixOps.rowPlusEquals (constraints, numFeatures,
                     labeling.indexAtLocation(pos),
                     fv,
                     instanceWeight*labeling.valueAtLocation(pos));
 
View Full Code Here

      // Here is the difference between this code and the single label
      //  version: rather than only picking out the "best" index,
      //  loop over all label indices.
     
      assert(labeling.numLocations() == trainingSet.getTargetAlphabet().size());
      for (int pos = 0; pos < labeling.numLocations(); pos++){
        MatrixOps.rowPlusEquals (constraints, numFeatures,
                     labeling.indexAtLocation(pos),
                     fv,
                     instanceWeight*labeling.valueAtLocation(pos));
      }
 
View Full Code Here

      }
      if (hasNaN)
        logger.info("NaN in instance: " + inst.getName());

      // For the default feature, whose weight is 1.0
      for (int pos = 0; pos < labeling.numLocations(); pos++) {
        constraints[labeling.indexAtLocation(pos)*numFeatures + defaultFeatureIndex] +=
          1.0 * instanceWeight * labeling.value(labeling.indexAtLocation(pos));
      }
    }
  }
 
View Full Code Here

        this.theClassifier.getClassificationScores (instance, scores);
        FeatureVector fv = (FeatureVector) instance.getData ();

        value = 0.0;
        for(int pos = 0; pos < labeling.numLocations(); pos++) { //loop, added by Limin Yao
          int ll = labeling.indexAtLocation(pos);
          if (scores[ll] == && labeling.valueAtLocation(pos) > 0) {
            logger.warning ("Instance "+instance.getSource() + " has infinite value; skipping value and gradient");
            cachedValue = Double.NEGATIVE_INFINITY;
            cachedValueStale = false;
View Full Code Here

      // Here is the difference between this code and the single label
      //  version: rather than only picking out the "best" index,
      //  loop over all label indices.
     
      for (int pos = 0; pos < labeling.numLocations(); pos++){
        MatrixOps.rowPlusEquals (constraints, numFeatures,
                     labeling.indexAtLocation(pos),
                     fv,
                     instanceWeight*labeling.valueAtLocation(pos));
      }
 
View Full Code Here

      }
      if (hasNaN)
        logger.info("NaN in instance: " + inst.getName());

      // For the default feature, whose weight is 1.0
      for (int pos = 0; pos < labeling.numLocations(); pos++) {
        constraints[labeling.indexAtLocation(pos)*numFeatures + defaultFeatureIndex] +=
          1.0 * instanceWeight * labeling.value(labeling.indexAtLocation(pos));
      }
    }
  }
 
View Full Code Here

        this.theClassifier.getClassificationScores (instance, scores);
        FeatureVector fv = (FeatureVector) instance.getData ();

            value = 0.0;
        for(int pos = 0; pos < labeling.numLocations(); pos++) { //loop, added by Limin Yao
          int ll = labeling.indexAtLocation(pos);
          value -= (instanceWeight * labeling.valueAtLocation(pos) * Math.log (scores[ll]));         
        }     

        if (Double.isNaN(value)) {
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.