Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsupported operand type(s) for *: map and map

Tags:

python

I am trying to debug the following code where I get the aforementioned error message: TypeError: unsupported operand type(s) for *: 'map' and 'map'

I did my fair search online and I understand that the square operation is not supported but I cannot fully understand how to resolve it.

My code is the following:

mahalanobis = lambda p: distance.mahalanobis(p, means, covariances.T)
d = np.array(map(mahalanobis, data))  # Mahalanobis distance values 
d2 = d ** 2  # MD squared

The error pops up in the square calculation. All data types are numpy.ndarrays.

like image 305
azal Avatar asked Feb 12 '18 12:02

azal


1 Answers

Convert map into list:

d = np.array(list(map(mahalanobis, data)))
like image 142
zipa Avatar answered Oct 01 '22 07:10

zipa