use of primal.primitive.adt.map.IntObjMap in project suite by stupidsing.
the class KmeansCluster method kNearestNeighbor.
public int kNearestNeighbor(List<float[]> points, float[] point0) {
var map = new IntObjMap<AtomicInteger>();
//
Read.from(//
points).index().map(//
(i, point) -> IntDblPair.of(i, sqdist(point0, point))).sortBy(//
pair -> pair.t1).take(//
points.size()).forEach(bin -> map.computeIfAbsent(bin.t0, c -> new AtomicInteger()).incrementAndGet());
return ReadInt.from2(map).min((k, v) -> -v.v.get()).k;
}
Also used :
ObjIntMap(primal.primitive.adt.map.ObjIntMap)
ReadInt(primal.primitive.IntMoreVerbs.ReadInt)
DblObjPair(primal.primitive.adt.pair.DblObjPair)
New(primal.Verbs.New)
Read(primal.MoreVerbs.Read)
IntDblPair(primal.primitive.adt.pair.IntDblPair)
ArrayList(java.util.ArrayList)
IntObjMap(primal.primitive.adt.map.IntObjMap)
List(java.util.List)
AtomicInteger(java.util.concurrent.atomic.AtomicInteger)
Vector(suite.math.linalg.Vector)
Map(java.util.Map)
LiftInt(primal.primitive.IntMoreVerbs.LiftInt)
Obj_Int(primal.primitive.IntPrim.Obj_Int)
Left(primal.Verbs.Left)
AtomicInteger(java.util.concurrent.atomic.AtomicInteger)
IntObjMap(primal.primitive.adt.map.IntObjMap)