Package gnu.trove.map.hash

Examples of gnu.trove.map.hash.TIntFloatHashMap$TIntFloatKeyHashIterator


    private float distanceEuclidean(int n, HashSparseVector sv, float baseDistance) {
        HashSparseVector center = classCenter.get(n);
        int count = classCount.get(n);
        float dist = baseDistance / (count * count);
        TIntFloatHashMap data = center.data;
        TIntFloatIterator it = sv.data.iterator();
        while (it.hasNext()) {
            it.advance();
            int key = it.key();
            if (!data.containsKey(key)) {
                dist += it.value() * it.value();
            }
            else {
                float temp = data.get(key) / count;
                dist -= temp * temp;
                dist += (it.value() - temp) * (it.value() - temp);
            }
        }
        return dist;
View Full Code Here


//        vectorcenter.scaleDivide((float)count / (float)(count+1));
    }

    private void updateBaseDist(int classid, HashSparseVector vector) {
        float base = baseDistList.get(classid);
        TIntFloatHashMap center = classCenter.get(classid).data;
        TIntFloatIterator it =  vector.data.iterator();
        while (it.hasNext()) {
            it.advance();
            if (!center.containsKey(it.key())) {
                base += it.value() * it.value();
            }
            else {
                float temp = center.get(it.key());
                base -= temp * temp;
                base += (it.value() - temp) * (it.value() - temp);
            }
        }
        baseDistList.set(classid, base);
View Full Code Here

*/
public class TByteShortByteKeyedFloatHashMap extends TByteShortByteKeyedMap {
  private TIntFloatHashMap map;

  public TByteShortByteKeyedFloatHashMap() {
    map = new TIntFloatHashMap(100);
  }
View Full Code Here

  public TByteShortByteKeyedFloatHashMap() {
    map = new TIntFloatHashMap(100);
  }

  public TByteShortByteKeyedFloatHashMap(int capacity) {
    map = new TIntFloatHashMap(capacity);
  }
View Full Code Here

*/
public class TByteTripleFloatHashMap {
  private TIntFloatHashMap map;

  public TByteTripleFloatHashMap() {
    map = new TIntFloatHashMap(100);
  }
View Full Code Here

  public TByteTripleFloatHashMap() {
    map = new TIntFloatHashMap(100);
  }

  public TByteTripleFloatHashMap(int capacity) {
    map = new TIntFloatHashMap(capacity);
  }
View Full Code Here

   * @throws IllegalArgumentException if the given selected attributes specify
   *         an attribute as selected which is out of range for the given
   *         SparseFloatVector.
   */
  public static SparseFloatVector project(SparseFloatVector v, BitSet selectedAttributes) {
    TIntFloatHashMap values = new TIntFloatHashMap(selectedAttributes.cardinality(), 1);
    for(int d = selectedAttributes.nextSetBit(0); d >= 0; d = selectedAttributes.nextSetBit(d + 1)) {
      if(v.getValue(d + 1) != 0.0f) {
        values.put(d, v.getValue(d + 1));
      }
    }
    SparseFloatVector projectedVector = new SparseFloatVector(values, selectedAttributes.cardinality());
    return projectedVector;
  }
View Full Code Here

  }

  @Override
  protected SparseFloatVector filterSingleObject(SparseFloatVector featureVector) {
    BitSet b = featureVector.getNotNullMask();
    TIntFloatHashMap vals = new TIntFloatHashMap();
    for(int i = b.nextSetBit(0); i >= 0; i = b.nextSetBit(i + 1)) {
      vals.put(i, (float) (featureVector.doubleValue(i) * idf.get(i)));
    }
    return new SparseFloatVector(vals, featureVector.getDimensionality());
  }
View Full Code Here

  }

  @Override
  public SparseFloatVector restore(SparseFloatVector featureVector) {
    BitSet b = featureVector.getNotNullMask();
    TIntFloatHashMap vals = new TIntFloatHashMap();
    for(int i = b.nextSetBit(0); i >= 0; i = b.nextSetBit(i + 1)) {
      vals.put(i, (float) (featureVector.doubleValue(i) / idf.get(i)));
    }
    return new SparseFloatVector(vals, featureVector.getDimensionality());
  }
View Full Code Here

      sum += featureVector.doubleValue(i);
    }
    if(sum <= 0) {
      sum = 1.0;
    }
    TIntFloatHashMap vals = new TIntFloatHashMap();
    for(int i = b.nextSetBit(0); i >= 0; i = b.nextSetBit(i + 1)) {
      vals.put(i, (float) (featureVector.doubleValue(i) / sum * idf.get(i)));
    }
    return new SparseFloatVector(vals, featureVector.getDimensionality());
  }
View Full Code Here

TOP

Related Classes of gnu.trove.map.hash.TIntFloatHashMap$TIntFloatKeyHashIterator

Copyright © 2018 www.massapicom. 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.