-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Inconsistent Results For Logistic Regressions across multiple computers #24615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Could you set the |
@glemaitre Of course - I should've included that in the code example. Setting
|
Could you try with a smaller |
I decreased the The number of iterations is also not the same, and when it is the same, the results are different. When the regularization increases, this behaviour will disappear. Note that this behaviour is also present with |
What happens with C=np.inf instead of C=1e42? |
It doesn't converge :) With LBFGS, since you have the verbose, you can see small numerical differences (in term of objective and gradient) at each iteration that leads the coefficients to diverge after a while. |
@NickBrecht, As liblinear approximate weights to minimize the cost function, getting different results might be possible due to small mathematical round off errors at the time of convergence. It also depends on
In the case of Tensorflow, We may directly use logits in cost function to avoid this type of round off errors. |
@MujassimJamal thanks for the input. I still am incredibly suspicious that differences in approximated weights & rounding could yield the nontrivial differences in the numbers above. If we saw a difference in the hundred thousandths then sure, but a .1-.2+ difference seems suspect. Do you feel otherwise? Iterations/learning rate were account for in many, many tests (and @glemaitre's test seemingly). I attempted to account for computational environments as stated in my original post. I'm aware that differences in the actual CPU architecture could yield some infinitely small differences, but same conda, python, blas, mkl, etc. |
I can‘t test for myself right now. Let‘s exclude collinearity and perfect separability:
|
Maybe the problem/target is separable, see also #18264. |
Describe the bug
Hey all -
I'm working on teaching some students some logistic regressions and noticed different computers can produce slightly different intercepts/coefs. At first I thought it was maybe environment differences, but I have been able to reproduce the variances when accounting for the various packages/interpreters.
I can create a new environment on computer 1 (windows 10, intel 8th gen CPU), computer 2 (windows 10, intel 11th gen CPU), and a coworker's M1 MacBook - all three produce different results. I thought maybe minute differences in Numpy's Openblas or MKL could be the culprit but that yielded the same varying results. I've tried not splitting the data, different random states, different C values, different solvers...
For the purposes of reproducibility, I ran this is exact code & uploaded the data to Google sheets:
All versions of all other packages are held constant. I received this results across the three computers:
I have tried many other things that all produce slightly different results that are not captured in the above table. Multicollinearity is present within the data, but I would still expect consistent results.
I understand the results are effectively the same and this produces little real world impacts. However, when a student is comparing results and they see 12.4 vs 12.6 which is a decently large difference. I think some of these differences are too large to just be contributed to floating-point computations -- especially for size of the data. I assume I'm missing something, but I'm reaching the end of my rope on troubleshooting. Thoughts / expected behavior?
Steps/Code to Reproduce
Expected Results
Actual Results
n/a
Versions
The text was updated successfully, but these errors were encountered: