statsmodel.api fit()抛出溢出错误

时间:2016-10-17 07:38:20

标签: python logistic-regression statsmodels mnist hessian-matrix

我使用Logistic回归进行Mnist数字分类,并使用statsmodel.api库来拟合参数,但Logit.fit()仍然会抛出溢出警告.Below是我在Windows10上遇到的错误,python 2.7使用库从http://www.lfd.uci.edu/~gohlke/pythonlibs/下载。

C:\Python27\lib\site-packages\statsmodels\discrete\discrete_model.py:1213: RuntimeWarning: overflow encountered in exp   return 1/(1+np.exp(-X)) C:\Python27\lib\site-packages\statsmodels\discrete\discrete_model.py:1263: RuntimeWarning: divide by zero encountered in log   return np.sum(np.log(self.cdf(q*np.dot(X,params)))) Warning: Maximum number of iterations has been exceeded.
         Current function value: inf
         Iterations: 35 Traceback (most recent call last):   File "code.py", line 44, in <module>
    result1 = logit1.fit()   File "C:\Python27\lib\site-packages\statsmodels\discrete\discrete_model.py", line 1376, in fit
    disp=disp, callback=callback, **kwargs)   File "C:\Python27\lib\site-packages\statsmodels\discrete\discrete_model.py", line 203, in fit
    disp=disp, callback=callback, **kwargs)   File "C:\Python27\lib\site-packages\statsmodels\base\model.py", line 434, in fit
    Hinv = np.linalg.inv(-retvals['Hessian']) / nobs   File "C:\Python27\lib\site-packages\numpy\linalg\linalg.py", line 526, in inv
    ainv = _umath_linalg.inv(a, signature=signature, extobj=extobj)   File "C:\Python27\lib\site-packages\numpy\linalg\linalg.py", line 90, in _raise_linalgerror_singular
    raise LinAlgError("Singular matrix") numpy.linalg.linalg.LinAlgError: Singular matrix

0 个答案:

没有答案