bayes_logistic icon indicating copy to clipboard operation
bayes_logistic copied to clipboard

AttributeError: 'float' object has no attribute 'exp'

Open vishpat opened this issue 8 years ago • 5 comments

Hit the following exception

/usr/local/lib/python2.7/dist-packages/bayes_logistic/bayes_logistic.py in logistic_prob(X, w) 62 63 # calculate logitstic probability ---> 64 pr = np.exp(z) 65 66 pr = pr / (1. + pr)

AttributeError: 'float' object has no attribute 'exp'

Following is the URL of the notebook that reproduces the error http://pastebin.com/EMWLqjF1

vishpat avatar Feb 12 '17 05:02 vishpat

I have the fix for the issue, so will open a PR for it.

vishpat avatar Feb 12 '17 05:02 vishpat

The error here is occurring because the y array in the notebook in #6 is coming from pandas as an object dtype. If you cast that to an int (y = y.astype(int)) or a bool (y = y.astype(bool)) then things will behave as expected.

ericdill avatar Feb 13 '17 00:02 ericdill

Yes, that seems to fix the Exception.

However without the change in PR #8 , the prediction accuracy of the model seems to change for every run (for the parkinson's notebook), which is weird and I don't understand yet.

vishpat avatar Feb 13 '17 02:02 vishpat

Also I have update PR #6 with the suggested change

vishpat avatar Feb 13 '17 02:02 vishpat

I have updated PR #8 to check for the data type of y.

vishpat avatar Feb 13 '17 18:02 vishpat