Examples of valueAtLocation()


Examples of cc.mallet.types.FeatureVector.valueAtLocation()

        // For the default feature, whose weight is 1.0
        assert(!Double.isNaN(instanceWeight)) : "instanceWeight is NaN";
        assert(!Double.isNaN(li)) : "bestIndex is NaN";
        boolean hasNaN = false;
        for(int i = 0; i < fv.numLocations(); i++) {
          if(Double.isNaN(fv.valueAtLocation(i))) {
            logger.info("NaN for feature " + fdict.lookupObject(fv.indexAtLocation(i)).toString());
            hasNaN = true;
          }
        }
        if(hasNaN)
View Full Code Here

Examples of cc.mallet.types.FeatureVector.valueAtLocation()

      FeatureCounter counter = wordCountsPerTopic[ti];
      FeatureVector fv = counter.toFeatureVector();
      for(int pos = 0; pos < fv.numLocations(); pos++){
        int fi = fv.indexAtLocation(pos);
        String word = (String) alphabet.lookupObject(fi);
        int count = (int) fv.valueAtLocation(pos);
        double prob;
        prob = (double) (count+beta)/(tokensPerTopic[ti] + betaSum);
        pw.println(word + "\t" + prob);
      }
      pw.println();
View Full Code Here

Examples of cc.mallet.types.FeatureVector.valueAtLocation()

      assert (features.getAlphabet() == alphabet);

      boolean hasNaN = false;

      for (int i = 0; i < features.numLocations(); i++) {
        if (Double.isNaN(features.valueAtLocation(i))) {
          logger.info("NaN for feature " + alphabet.lookupObject(features.indexAtLocation(i)).toString());
          hasNaN = true;
        }
      }
View Full Code Here

Examples of cc.mallet.types.FeatureVector.valueAtLocation()

        Dirichlet.digamma(sumScores + totalLength) -
        Dirichlet.digamma(sumScores);
     
      for (int loc = 0; loc < features.numLocations(); loc++) {
        int index = features.indexAtLocation(loc);
        double value = features.valueAtLocation(loc);
                   
        if (value == 0.0) { continue; }

        // In a FeatureVector, there's no easy way to say "do you know
        //   about this id?" so I've broken this into two for loops,
View Full Code Here

Examples of cc.mallet.types.FeatureVector.valueAtLocation()

        // compute dot(x, wi) for each class i
        for(int lpos = 0; lpos < numLabels; lpos++) {
          for(int fvi = 0; fvi < fvisize; fvi++) {
            int fi = fv.indexAtLocation(fvi);
            double vi = fv.valueAtLocation(fvi);
            results[lpos] += vi * m_weights[lpos][fi];
          }

          // This extra value comes from the extra
          // "feature" present in all examples
View Full Code Here

Examples of cc.mallet.types.FeatureVector.valueAtLocation()

          double val;
          if (!useValues) {
            val = 1.;
          }
          else {
            val = fv.valueAtLocation(loc);
          }
          featureCounts[cIndex] += val;
          for (int l = 0; l < numLabels; l++) {
            modelExpectations[cIndex][l] += scores[ii][l] * val * instanceWeight;
          }
View Full Code Here

Examples of cc.mallet.types.FeatureVector.valueAtLocation()

          double val;
          if ((featureIndex == defaultFeatureIndex)||(!useValues)) {
            val = 1;
          }
          else {
            val = fv.valueAtLocation(loc);
          }
         
          // compute \sum_y p(y|x) \hat{g}_y / \bar{g}_y
          double instanceExpectation = 0;
          for (int label = 0; label < numLabels; label++) {
View Full Code Here

Examples of cc.mallet.types.FeatureVector.valueAtLocation()

      int i = 0;
      while (keyIter.hasNext()) {
        int fi = keyIter.next();
        if (fv.location(fi) >= 0) {
          for (int li = 0; li < numLabels; li++) {
            featureCounts[i][li] += labelDist[li] * fv.valueAtLocation(fv.location(fi));
          }
        }
        i++;
      }
    }
View Full Code Here

Examples of cc.mallet.types.FeatureVector.valueAtLocation()

      // this handles distributions over labels
      for (int li = 0; li < numLabels; li++) {
        double py = instance.getLabeling().value(li);
        for (int loc = 0; loc < featureVector.numLocations(); loc++) {
          int fi = featureVector.indexAtLocation(loc);
          double val = featureVector.valueAtLocation(loc);
          featureLabelCounts[fi][li] += py * val;
        }
      }
    }
    return featureLabelCounts;
View Full Code Here

Examples of cc.mallet.types.FeatureVector.valueAtLocation()

      assert(!Double.isNaN(instanceWeight)) : "instanceWeight is NaN";

      boolean hasNaN = false;
      for (int i = 0; i < fv.numLocations(); i++) {
        if (Double.isNaN(fv.valueAtLocation(i))) {
          logger.info("NaN for feature " + fdict.lookupObject(fv.indexAtLocation(i)).toString());
          hasNaN = true;
        }
      }
      if (hasNaN)
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.