0

I'm trying to build a model using Logistic Regression, but I'm getting a warning/errors when running this:

mdl = fitglm(X, Y, 'distr', 'binomial', 'link', 'logit')

Here are the errors:

Warning: Iteration limit reached. 
 In glmfit (line 368)
 In GeneralizedLinearModel/fitter (line 920)
 In classreg.regr.FitObject/doFit (line 220)
 In GeneralizedLinearModel.fit (line 1245)
 In fitglm (line 134)

Can someone please explain why I'm getting these errors, and how to fix them. Thank you

Pavel Oganesyan
  • 6,774
  • 4
  • 46
  • 84
K. Am
  • 51
  • 5
  • It may be caused by your data nature - read accepted answer in this thread - http://www.mathworks.com/matlabcentral/answers/153259-how-to-fix-iteration-limit-reached-warning?requestedDomain=www.mathworks.com – Pavel Oganesyan Apr 19 '16 at 16:31
  • I highly suspect it is because of the dynamic range of each of the features in your data. One of your features may have a very large dynamic range in comparison to another feature. Simply put, try normalizing each of your features then train your model. However when you make predictions, make sure you normalize by the same mean and standard deviation that resulted from the training set then use this to perform your predictions. I've marked a suitable duplicate so you can look at the code required to do this. – rayryeng Apr 19 '16 at 16:34
  • @rayryeng I am not sure these questions are exact duplicates. You have a brilliant answer there, but in terms of searching this error on the Internet this question is not a duplicate of that thread. – Pavel Oganesyan Apr 19 '16 at 16:39
  • @PavelOganesyan Why don't we let the OP try it and if it doesn't work, I'll reopen? – rayryeng Apr 19 '16 at 16:41
  • Some of my data is categorical, which I've converted to dummy variables. The rest of variables is numerical, which I normalized. Is the combination of dummy variables and normalized numerical variables in the model causing the issues? – K. Am Apr 19 '16 at 17:08
  • @rayryeng Could you please reopen this? Thank you – K. Am Apr 19 '16 at 20:45
  • 1
    @K.Am: I suggest making a minimal runnable example so that we can try to replicate this issue. Also indicate your Matlab `version`. – horchler Jun 21 '16 at 14:23

0 Answers0