Last answered:

15 Nov 2021

Posted on:

12 Nov 2021

0

during results_log = reg_log.fit(), error encounter but code runs

C:\Users\Kanva\anaconda3\lib\site-packages\statsmodels\discrete\discrete_model.py:1819: RuntimeWarning: overflow encountered in exp
  return 1/(1+np.exp(-X))
C:\Users\Kanva\anaconda3\lib\site-packages\statsmodels\discrete\discrete_model.py:1872: RuntimeWarning: divide by zero encountered in log
  return np.sum(np.log(self.cdf(q*np.dot(X,params))))

also, on running results_log.summary() ---
image.png

where am I wrong?.. or what setting do I need to edit to not encounter such error in the future?

2 answers ( 0 marked as helpful)
Instructor
Posted on:

15 Nov 2021

0

Hey Kanva,

Thank you for your question!

Unfortunately, I don't see any immediate errors with the code. Could you try restarting your notebook using the button shown below and then running the code again? Is the error still there?
image.png
If yes, could you tell me which version of statsmodels you are using? This you can do by typing

import statsmodels
statsmodels.__version__

anywhere in the notebook. Could you also tell me the name of the notebook you are trying to run? Have you made any changes to the code or are you using the original version of the notebook?

Kind regards,
365 Hristina

Posted on:

15 Nov 2021

0

I tried once more and I noticed that I did pd.get_dummies for mapping instead of .map(...)... and the latter seemed to give me the correct results without the earlier error...
But.. is there a difference between these 2 methods??..

data = pd.get_dummies(raw_data, drop_first = True)
data = data.rename(columns = {"Admitted_Yes":"Admitted"})

v/s

data = raw_data.copy()
data['Admitted'] = data['Admitted'].map({'Yes':1,'No':0})

I printed data and it looked the same to me
so.. I compared the data type in the 2 cases..
pd.get_dummies's 1's and 0's are numpy.uint8 while .map one's are numpy.int64

I guess that's why the error was thrown... should I just avoid .get_dummies() or something else?... pls suggesttt....

Thanksz!

Submit an answer