What is most efficient way to find the mode per row in a multi-dimensional array of the non-zero elements?
For example:
[
[0. 0.4 0.6 0. 0.6 0. 0.6 0. 0. 0.6 0. 0.6 0.6 0.6 0. 0. 0. 0.6
0. 0. 0. 0. 0. 0. 0. 0. 0.5 0.6 0. 0. 0.6 0.6 0.6 0. 0. 0.6
0.6 0.6 0. 0.5 0.6 0.6 0. 0. 0.6 0. 0.6 0. 0. 0.6],
[0. 0.1 0.2 0.1 0. 0.1 0.1 0.1 0. 0.1 0. 0. 0. 0.1 0.1 0. 0.1 0.1
0. 0.1 0.1 0.1 0. 0.1 0.1 0.1 0. 0.1 0.2 0. 0.1 0.1 0. 0.1 0.1 0.1
0. 0.2 0.1 0. 0.1 0. 0.1 0.1 0. 0.1 0. 0.1 0. 0.1]
]
The mode of the above is [0, 0.1]
, but ideally we want to return [0.6, 0.1]
.