A SparseFloatVector is to store real values approximately as float values.
179180181182183184185186
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; }
59606162636465
} @Override protected SimpleTypeInformation<? super SparseFloatVector> convertedType(SimpleTypeInformation<SparseFloatVector> in) { final Map<Integer, Float> emptyMap = Collections.emptyMap(); return new VectorFieldTypeInformation<SparseFloatVector>(SparseFloatVector.class, k, new SparseFloatVector(emptyMap, k)); }
414415416417418419420421
102103104105106107108
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()); }
112113114115116117118
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()); }
60616263646566
} 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()); }
125126127128129130131
} if(curterm != null) { labels.add(curterm); } return new Pair<SparseFloatVector, LabelList>(new SparseFloatVector(values, maxdim), labels); }
156157158159160161162
} @Override protected VectorFieldTypeInformation<SparseFloatVector> getTypeInformation(int dimensionality) { final Map<Integer, Float> emptyMap = Collections.emptyMap(); return new VectorFieldTypeInformation<SparseFloatVector>(SparseFloatVector.class, dimensionality, new SparseFloatVector(emptyMap, dimensionality)); }
} Map<Integer, Float> vals = new HashMap<Integer, Float>(); for(int i = b.nextSetBit(0); i >= 0; i = b.nextSetBit(i + 1)) { vals.put(i, (float) (featureVector.doubleValue(i) / sum * idf.get(i).doubleValue())); } return new SparseFloatVector(vals, featureVector.getDimensionality()); }
56575859606162
} @Override protected SimpleTypeInformation<? super SparseFloatVector> convertedType(SimpleTypeInformation<SparseFloatVector> in) { initializeRandomAttributes(in); return new VectorFieldTypeInformation<SparseFloatVector>(SparseFloatVector.class, k, new SparseFloatVector(SparseFloatVector.EMPTYMAP, k)); }