No convergence warning in logistic regression
Dear all, I compared the logistic regression of statsmodels (Logit) with the logistic regression of sklearn (LogisticRegression). As I do not do regularization, I use the fit method with statsmodels and set penalty='none' in sklearn. Most of the time, I have got the same results between the two packages. However, when data are correlated, it is not the case. In fact, I have got a very useful convergence warning with statsmodel (ConvergenceWarning: Maximum Likelihood optimization failed to converge) that I do not have with sklearn? Is it normal that I do not have any convergence warning with sklearn even if I put verbose=1? I guess sklearn did not converge either. Thanks for your help, Best regards, Ben
Hi Ben, I can recall seeing convergence warnings for scikit-learn's logistic regression model on datasets in the past as well. Which solver did you use for LogisticRegression in sklearn? If you haven't done so, have used the lbfgs solver? I.e., LogisticRegression(..., solver='lbfgs')? Best, Sebastian
On Aug 30, 2019, at 9:52 AM, Benoît Presles <benoit.presles@u-bourgogne.fr> wrote:
Dear all,
I compared the logistic regression of statsmodels (Logit) with the logistic regression of sklearn (LogisticRegression). As I do not do regularization, I use the fit method with statsmodels and set penalty='none' in sklearn. Most of the time, I have got the same results between the two packages.
However, when data are correlated, it is not the case. In fact, I have got a very useful convergence warning with statsmodel (ConvergenceWarning: Maximum Likelihood optimization failed to converge) that I do not have with sklearn? Is it normal that I do not have any convergence warning with sklearn even if I put verbose=1? I guess sklearn did not converge either.
Thanks for your help, Best regards, Ben _______________________________________________ scikit-learn mailing list scikit-learn@python.org https://mail.python.org/mailman/listinfo/scikit-learn
Hello Sebastian, I have tried with the lbfgs solver and it does not change anything. I do not have any convergence warning. Thanks for your help, Ben Le 30/08/2019 à 18:29, Sebastian Raschka a écrit :
Hi Ben,
I can recall seeing convergence warnings for scikit-learn's logistic regression model on datasets in the past as well. Which solver did you use for LogisticRegression in sklearn? If you haven't done so, have used the lbfgs solver? I.e.,
LogisticRegression(..., solver='lbfgs')?
Best, Sebastian
On Aug 30, 2019, at 9:52 AM, Benoît Presles <benoit.presles@u-bourgogne.fr> wrote:
Dear all,
I compared the logistic regression of statsmodels (Logit) with the logistic regression of sklearn (LogisticRegression). As I do not do regularization, I use the fit method with statsmodels and set penalty='none' in sklearn. Most of the time, I have got the same results between the two packages.
However, when data are correlated, it is not the case. In fact, I have got a very useful convergence warning with statsmodel (ConvergenceWarning: Maximum Likelihood optimization failed to converge) that I do not have with sklearn? Is it normal that I do not have any convergence warning with sklearn even if I put verbose=1? I guess sklearn did not converge either.
Thanks for your help, Best regards, Ben _______________________________________________ scikit-learn mailing list scikit-learn@python.org https://mail.python.org/mailman/listinfo/scikit-learn
scikit-learn mailing list scikit-learn@python.org https://mail.python.org/mailman/listinfo/scikit-learn
LBFGS will raise ConvergenceWarning for sure. You can check the n_iter_ attribute to know if you really converged. On Mon, 2 Sep 2019 at 10:28, Benoît Presles <benoit.presles@u-bourgogne.fr> wrote:
Hello Sebastian,
I have tried with the lbfgs solver and it does not change anything. I do not have any convergence warning.
Thanks for your help, Ben
Hi Ben,
I can recall seeing convergence warnings for scikit-learn's logistic regression model on datasets in the past as well. Which solver did you use for LogisticRegression in sklearn? If you haven't done so, have used the lbfgs solver? I.e.,
LogisticRegression(..., solver='lbfgs')?
Best, Sebastian
On Aug 30, 2019, at 9:52 AM, Benoît Presles < benoit.presles@u-bourgogne.fr> wrote:
Dear all,
I compared the logistic regression of statsmodels (Logit) with the logistic regression of sklearn (LogisticRegression). As I do not do regularization, I use the fit method with statsmodels and set
Le 30/08/2019 à 18:29, Sebastian Raschka a écrit : penalty='none' in sklearn. Most of the time, I have got the same results between the two packages.
However, when data are correlated, it is not the case. In fact, I have
got a very useful convergence warning with statsmodel (ConvergenceWarning: Maximum Likelihood optimization failed to converge) that I do not have with sklearn? Is it normal that I do not have any convergence warning with sklearn even if I put verbose=1? I guess sklearn did not converge either.
Thanks for your help, Best regards, Ben _______________________________________________ scikit-learn mailing list scikit-learn@python.org https://mail.python.org/mailman/listinfo/scikit-learn
_______________________________________________ scikit-learn mailing list scikit-learn@python.org https://mail.python.org/mailman/listinfo/scikit-learn
scikit-learn mailing list scikit-learn@python.org https://mail.python.org/mailman/listinfo/scikit-learn
-- Guillaume Lemaitre INRIA Saclay - Parietal team Center for Data Science Paris-Saclay https://glemaitre.github.io/
Having correlated data is not the same as not converging. We could warn on correlated data but I don't think that's actually useful for scikit-learn. I actually recently argued to remove the warning in linear discriminant analysis: https://github.com/scikit-learn/scikit-learn/issues/14361 As argued in many places, we're not a stats library and as long as there's a well-defined solution, there's no reason to warn. LogisticRegression will give you the solution with minimum coefficient norm if there's multiple solutions. On 9/2/19 5:40 AM, Guillaume Lemaître wrote:
LBFGS will raise ConvergenceWarning for sure. You can check the n_iter_ attribute to know if you really converged.
On Mon, 2 Sep 2019 at 10:28, Benoît Presles <benoit.presles@u-bourgogne.fr <mailto:benoit.presles@u-bourgogne.fr>> wrote:
Hello Sebastian,
I have tried with the lbfgs solver and it does not change anything. I do not have any convergence warning.
Thanks for your help, Ben
Le 30/08/2019 à 18:29, Sebastian Raschka a écrit : > Hi Ben, > > I can recall seeing convergence warnings for scikit-learn's logistic regression model on datasets in the past as well. Which solver did you use for LogisticRegression in sklearn? If you haven't done so, have used the lbfgs solver? I.e., > > LogisticRegression(..., solver='lbfgs')? > > Best, > Sebastian > >> On Aug 30, 2019, at 9:52 AM, Benoît Presles <benoit.presles@u-bourgogne.fr <mailto:benoit.presles@u-bourgogne.fr>> wrote: >> >> Dear all, >> >> I compared the logistic regression of statsmodels (Logit) with the logistic regression of sklearn (LogisticRegression). As I do not do regularization, I use the fit method with statsmodels and set penalty='none' in sklearn. Most of the time, I have got the same results between the two packages. >> >> However, when data are correlated, it is not the case. In fact, I have got a very useful convergence warning with statsmodel (ConvergenceWarning: Maximum Likelihood optimization failed to converge) that I do not have with sklearn? Is it normal that I do not have any convergence warning with sklearn even if I put verbose=1? I guess sklearn did not converge either. >> >> >> Thanks for your help, >> Best regards, >> Ben >> _______________________________________________ >> scikit-learn mailing list >> scikit-learn@python.org <mailto:scikit-learn@python.org> >> https://mail.python.org/mailman/listinfo/scikit-learn > _______________________________________________ > scikit-learn mailing list > scikit-learn@python.org <mailto:scikit-learn@python.org> > https://mail.python.org/mailman/listinfo/scikit-learn _______________________________________________ scikit-learn mailing list scikit-learn@python.org <mailto:scikit-learn@python.org> https://mail.python.org/mailman/listinfo/scikit-learn
-- Guillaume Lemaitre INRIA Saclay - Parietal team Center for Data Science Paris-Saclay https://glemaitre.github.io/
_______________________________________________ scikit-learn mailing list scikit-learn@python.org https://mail.python.org/mailman/listinfo/scikit-learn
participants (4)
-
Andreas Mueller -
Benoît Presles -
Guillaume Lemaître -
Sebastian Raschka