[K/N] Replaced usage of minBy/maxBy in samples and benchmarks
This commit is contained in:
committed by
Pavel Punegov
parent
d2d324797b
commit
53c80cf03b
+1
-1
@@ -33,7 +33,7 @@ class Greedy(private val graph: Graph) {
|
|||||||
val nodes = node.neighbors
|
val nodes = node.neighbors
|
||||||
.filter { it.value != 0 && !visitedNodes.contains(it.key) }
|
.filter { it.value != 0 && !visitedNodes.contains(it.key) }
|
||||||
val clostest = nodes
|
val clostest = nodes
|
||||||
.minBy { it.value }!!
|
.minByOrNull { it.value }!!
|
||||||
return ClosestNode(clostest.key, clostest.value)
|
return ClosestNode(clostest.key, clostest.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ fun Float.toRoundedString(digits: Int = 0): String {
|
|||||||
|
|
||||||
fun Float.toPercentageString(roundToDigits: Int = 1) = (this * 100).toRoundedString(roundToDigits)
|
fun Float.toPercentageString(roundToDigits: Int = 1) = (this * 100).toRoundedString(roundToDigits)
|
||||||
|
|
||||||
fun List<Float>.maxIndex() = withIndex().maxBy { it.value }!!.index
|
fun List<Float>.maxIndex() = withIndex().maxByOrNull { it.value }!!.index
|
||||||
|
|
||||||
fun accuracy(predictionBatch: FloatMatrix, labelBatch: FloatMatrix): Float {
|
fun accuracy(predictionBatch: FloatMatrix, labelBatch: FloatMatrix): Float {
|
||||||
val resultIndexes = predictionBatch.toList().map { it.maxIndex() }
|
val resultIndexes = predictionBatch.toList().map { it.maxIndex() }
|
||||||
|
|||||||
Reference in New Issue
Block a user