ValueError: Integers to negative integer powers are not allowed.

649 views
Skip to first unread message

Devin Shanahan

unread,
Mar 20, 2018, 9:26:26 AM3/20/18
to mlpy-general
I am encountering a ValueError: Integers to negative integer powers are not allowed. I am experiencing this error in both mlpy/da.py and mlpy/parzen.py.  This seems to be due to the array for y being cast as dtype=np.int.  This results in numpy raising an error in the following lines:

da.py

line 208, in learn

    mk = np.sqrt(nk**-1 - n**-1)


parzen.py

line 86, in learn

    alphaplus = np.where(ynew==1, nplus**-1, 0)


The values for nk, n, nplus are all derived from y and therefore have the np.int dtype as well.


Is anyone else having this same issue? Is there a way that I can resolve this?


Thanks,


Devin

nody yu

unread,
Apr 13, 2018, 10:55:00 AM4/13/18
to mlpy-general


Devin Shanahan於 2018年3月20日星期二 UTC+8下午9時26分26秒寫道:
In  line 86, in learn

    

     alphaplus = np.where(ynew==1, nplus**-1, 0)


you can change it to :


     alphaplus = np.where(ynew==1, 1/nplus, 0)



mine: python3.5 numpy 0.18

Reply all
Reply to author
Forward
0 new messages