How to fix Statsmodel warning: “Maximum no. of iterations has exceeded”

后端 未结 2 2140
囚心锁ツ
囚心锁ツ 2021-02-14 20:08

I am using Anaconda and I am trying logistic regression. After loading training data set and performed the regression. Then I got the following warning message.



        
相关标签:
2条回答
  • 2021-02-14 20:50

    There are two possibilities

    1) difficult optimization problem: Usually Logit converges very fast and the default number of iteration is set very low. Adding a larger maxiter keyword in the call to fit or refitting with the previous result as start_params helps in most cases.

    2) Since this is Logit, it is possible that there is complete separation, or quasi-complete separation. In this case some parameters might go off to infinity and the optimization stops at some convergence or stopping criterion. Logit detect the simple case of full separation and raises an exception, but there could be partial separation that is not detected. With perfect separation you get perfect predictability for some or all cases, which is useful for prediction but causes problems in estimating and identifying the parameters. More information is for example here https://stats.stackexchange.com/questions/11109/how-to-deal-with-perfect-separation-in-logistic-regression There are also several FAQ issues on the statsmodels github issues for corner cases and problems like this.

    0 讨论(0)
  • 2021-02-14 20:51

    Check for the levels of all variables. It might be possible that one amongst them would have almost 99% of one category. Hence making it difficult to converge. I resolved it by removing that variable from my dataset.

    0 讨论(0)
提交回复
热议问题