Python Forum
nanmean - np - np.mean - errror
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
nanmean - np - np.mean - errror
#1
I have fairly simple code to calculate mean. Basically I am reading mnist data, find the PCA and finding the mean of PCA1 and PCA2. The first few columns of PCA1, PCA2 are shown below. I am trying to find the mean of that data. I am confused how the mean could be something like e -power- negative 14.  Something is going wrong. I tried plain np.mean with axis=0, then nanmean - still the mean looks way off. If I chop off the last row it seemed to work at times. That is not consistent. The mean seems to be way out of range. The minimum is something like -1550 and max is like 1400 and for column 2 - 1300 to +2200. The mean could not be that small like e to power -14. 

Please help.
def findMean(X):
    X = X.astype('float64')
    badMU=np.nanmean(X,axis=0);
    print("from inside findMean print two rows of mean" )
    print(badMU[0:2])

    return badMU
Here is the output - excerpt only.
Output:
Print columns 1 and 2 of 5 rows of P i.e., P[:5,0:2] [[ -177.01262488 -1123.38369215]  [ -486.95502974   953.72782595]  [ -701.57667656   722.54538116]  [ -739.68606132   625.34125527]  [  496.35283147  -371.99788225]] Recovering X Test overall mean of P - just print a few cols from inside findMean print two rows of mean [ -3.54114684e-14  -1.08559058e-14] get min and max for col0 and col1 from P Num entries in P is = 12593
Reply


Messages In This Thread
nanmean - np - np.mean - errror - by venkim_python - Nov-28-2016, 07:22 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python indentation errror and output error jazzy 4 3,387 Sep-19-2018, 09:35 AM
Last Post: jazzy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020