use of org.apache.ignite.ml.math.primitives.vector.impl.DelegatingNamedVector in project ignite by apache.
the class VectorUtils method of.
/**
* Creates named vector based on map of keys and values.
*
* @param values Values.
* @return Named vector.
*/
public static NamedVector of(Map<String, Double> values) {
SparseVector vector = new SparseVector(values.size());
for (int i = 0; i < values.size(); i++) vector.set(i, Double.NaN);
Map<String, Integer> dict = new HashMap<>();
int idx = 0;
for (Map.Entry<String, Double> e : values.entrySet()) {
dict.put(e.getKey(), idx);
vector.set(idx, e.getValue());
idx++;
}
return new DelegatingNamedVector(vector, dict);
}
Aggregations