0
votes

I have an array of arrays and I need to calculate the z-score for each array i.e. z-score for each row in that array of arrays.

My code:

for x in train_image_resize:
    train_image_resize_mean = scipy.stats.zscore(x)

Error: C:\ProgramData\Anaconda3\lib\site-packages\scipy\stats\stats.py:2253: RuntimeWarning: invalid value encountered in true_divide return (a - mns) / sstd

If I do scipy.stats.zscore(train_image_resize), then it calculates the z-score of each number in the array of arrays. However, I wish to calculate one z-score for each array.

1

1 Answers

0
votes

This would indicate that you are dividing by zero, i.e. that the sample standard deviation vanishes; for example:

In [5]: scipy.stats.zscore([1, 1])
..\miniconda3\lib\site-packages\scipy\stats\stats.py:2315: RuntimeWarning: invalid value encountered in true_divide
  return (a - mns) / sstd
Out[5]: array([nan, nan])