@ Override public Map < String , Double > predict ( Tuple predict ) { KNNEngine engine = new KNNEngine ( predict , trainingData , k ) ; if ( mode == 1 ) { engine . getDistance ( engine . chebyshevDistance ) ; } else if ( mode == 2 ) { engine . getDistance ( engine . manhattanDistance ) ; } else { engine . getDistance ( engine . euclideanDistance ) ; } predict . label = engine . getResult ( ) ; Map < String , Double > outputMap = new ConcurrentHashMap <> ( ) ; trainingData . parallelStream ( ) . forEach ( x -> outputMap . put ( String . valueOf ( x . id ) , ( Double ) x . getExtra ( ) . get ( DISTANCE ) ) ) ; return outputMap ; }
Return the predict to every other train vector s distance .