groovy - Get all elements at index in 2d array -
i writing ml algorithm have list of tuples so:
[ [17582.0, 6.382129, 0.876581], [9868.0, 2.694977, 0.432818], [18333.0, 3.951256, 0.3333] ...]
so, index=0 refer specific value feature. normalize, need min , max of every feature.
is there short hand way elements @ index = 0 or index = 1, , on of tuples?
assuming values in variable list
then can do:
def firstelements = list*.head()
if need specific position, can do:
def secondelements = list*.getat(1)
to column-wise min , max, transpose list, calculation:
def cwminmax = list.transpose().collect { [it.min(), it.max()] }
Comments
Post a Comment