Examples of numLocations()


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

  {
    HashedSparseVector s = (HashedSparseVector) s1.cloneMatrix ();
    s.incrementValue (5, 0.75);

    double[] ans = new double[] {1, 2.75, 3, 4, 5};
    for (int i = 0; i < s.numLocations(); i++) {
      assertTrue (s.valueAtLocation (i) == ans[i]);
    }
  }

 
View Full Code Here

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

  {
    HashedSparseVector s = (HashedSparseVector) s1.cloneMatrix ();
    s.setValue (5, 0.3);

    double[] ans = new double[] {1, 0.3, 3, 4, 5};
    for (int i = 0; i < s.numLocations(); i++) {
      assertTrue (s.valueAtLocation (i) == ans[i]);
    }
  }

  private static int[] idx2 = { 3, 7, 12, 15, 18 };
View Full Code Here

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

  }

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

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

    s.plusEqualsSparse (s4, 1.0);
    checkAnswer (s, new double[] { 3, 5, 7.2, 6.8, 8.2 });

    IndexedSparseVector s5 = new IndexedSparseVector (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);
    }

    IndexedSparseVector s6 = new IndexedSparseVector (new int[] { 7 }, new double[] { 0.2 });
View Full Code Here

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

   * @return An array containing a score for each of the elements of <code>neighbors</code>.
   */
  public double[] evaluate (Neighbor[] neighbors) {
    double[] scores = new double[neighbors.length];
    LabelVector ranks = classifier.classify(neighbors).getLabelVector();
    for (int i = 0; i < ranks.numLocations(); i++) {
      int idx = ((Integer)ranks.getLabelAtRank(i).getEntry()).intValue();
      scores[idx] = ranks.getValueAtRank(i);
    }
    return scores;
  }
View Full Code Here

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

  {
    Classification c = underlyingClassifier.classify (instance);
    Classification cpc = confidencePredictingClassifier.classify (c);
    LabelVector lv = c.getLabelVector();
    int bestIndex = lv.getBestIndex();
    double [] values = new double[lv.numLocations()];
    //// Put score of "correct" into score of the winning class...
    // xxx Can't set lv - it's immutable.
    //     Must create copy and new classification object
    // lv.set (bestIndex, cpc.getLabelVector().value("correct"));
    //for (int i = 0; i < lv.numLocations(); i++)
View Full Code Here

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

    //  if (i != bestIndex)
    //    lv.set (i, 0.0);

    // Put score of "correct" in winning class and
    // set rest to 0
    for (int i = 0; i < lv.numLocations(); i++) {
      if (i != bestIndex)
        values[i] = 0.0;
      else values[i] = cpc.getLabelVector().value("correct");
    }
    //return c;
View Full Code Here

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

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

      // 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

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

      // 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
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.