-
-
Save retrospectacus/0ead737903757c12ea2d6b1a76dc19ee to your computer and use it in GitHub Desktop.
This file contains hidden or 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(List.empty[TopN]) { case (topNVec, mod) => | |
val res = calcDistance(spec, mod) | |
val newTopN = TopN(res.modelElm.label.get, res.distance) | |
(topNVec :+ newTopN).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