Last answered:

15 Nov 2021

Posted on:

12 Nov 2021


during results_log =, error encounter but code runs

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

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

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)
Posted on:

15 Nov 2021


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?
If yes, could you tell me which version of statsmodels you are using? This you can do by typing

import statsmodels

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


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"})


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....


Submit an answer