Created
May 2, 2018 21:00
-
-
Save zeryx/3d511e54fa3b25c7b33d6182c406964f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val result: Stream[Task, Prediction] = specimenStream.flatMap((spec: Document) =>{ | |
modelStream.fold(ListBuffer.empty[TopN]) { case (topNVec, mod) => | |
val res = calcDistance(spec, mod) | |
topNVec += TopN(res.modelElm.label.get, res.distance) | |
topNVec.sortBy(res => res.confidence).take(nearest) | |
}.map(topNVec => Prediction(spec.text, topNVec.toList) ) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment