Examples of indexAtLocation()


Examples of cc.mallet.types.IndexedSparseVector.indexAtLocation()

    }

    IndexedSparseVector s6 = new IndexedSparseVector (new int[] { 7 }, new double[] { 0.2 });
    s6.plusEqualsSparse (s1, 3.5);
    for (int i = 0; i < s6.numLocations(); i++) {
      assertEquals (7, s6.indexAtLocation (i));
      assertEquals (10.7, s6.valueAtLocation (i), 0.0);
    }
  }

  public void testDotProduct () {
View Full Code Here

Examples of cc.mallet.types.IndexedSparseVector.indexAtLocation()

  public void testCloneMatrixZeroed ()
  {
    IndexedSparseVector s = (IndexedSparseVector) s1.cloneMatrixZeroed ();
    for (int i = 0; i < s.numLocations(); i++) {
      assertTrue (s.valueAtLocation (i) == 0.0);
      assertTrue (s.indexAtLocation (i) == idxs [i]);
    }
  }

  public void testEmptyLocations ()
  {
View Full Code Here

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

      // 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);
      // This relies on labelWeight summing to 1 over all labels
View Full Code Here

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

      //  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));
      }

      assert(!Double.isNaN(instanceWeight)) : "instanceWeight is NaN";
View Full Code Here

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

      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

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

        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));
      }
    }
  }

  public MaxEnt getClassifier () { return theClassifier; }
View Full Code Here

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

        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;
            return cachedValue;
View Full Code Here

Examples of cc.mallet.types.SparseVector.indexAtLocation()

    checkAnswer (s, new double[] { 3, 5, 7.2, 6.8, 8.2 })

    SparseVector s5 = new SparseVector (new int[] { 7 }, new double[] { 0.2 });
    s5.plusEqualsSparse (s1);
    for (int i = 0; i < s5.numLocations(); i++) {
      assertEquals (7, s5.indexAtLocation (i));
      assertEquals (3.2, s5.valueAtLocation (i), 0.0);
    }

    SparseVector s6 = new SparseVector (new int[] { 7 }, new double[] { 0.2 });
    s6.plusEqualsSparse (s1, 3.5);
View Full Code Here

Examples of cc.mallet.types.SparseVector.indexAtLocation()

    }

    SparseVector s6 = new SparseVector (new int[] { 7 }, new double[] { 0.2 });
    s6.plusEqualsSparse (s1, 3.5);
    for (int i = 0; i < s6.numLocations(); i++) {
      assertEquals (7, s6.indexAtLocation (i));
      assertEquals (10.7, s6.valueAtLocation (i), 0.0);
    }
  }

  public void testDotProduct () {
View Full Code Here

Examples of cc.mallet.types.SparseVector.indexAtLocation()

  public void testCloneMatrixZeroed ()
  {
    SparseVector s = (SparseVector) s1.cloneMatrixZeroed ();
    for (int i = 0; i < s.numLocations(); i++) {
      assertTrue (s.valueAtLocation (i) == 0.0);
      assertTrue (s.indexAtLocation (i) == idxs [i]);
    }
  }

  public void testPrint ()
  {
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.