-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
add init_score & test cpp and python result consistency #1007
Conversation
@wxchan sure, I will check it |
@wxchan I think the reason is the different parameters. |
@guolinke but I read params from train.conf files, it should be the same. The strange thing is only a few of samples fail. |
@wxchan i found the trained model is exact the same, but the prediction is not. |
@guolinke maybe something to do with those fields like init_score? It passed when I removed init_score. |
@wxchan really ? I think the init_score should have no impact on prediction. |
@wxchan if replaced it with the std::stod, everything seems fine.
|
@wxchan however, stod seems very slow: https://tinodidriksen.com/2011/05/cpp-convert-string-to-double-speed/ |
@guolinke does it cause by some feature values near thresholds fall into different sub-trees because the precision of model? |
@wxchan yeah, exactly. I am trying to update atof . |
@wxchan can you try to replace the Atof with:
|
strange, I can pass the test of binary classification test locally |
@wxchan did chech the dtypes of np.loadtext? it is float64 in my local machine. |
@guolinke it's float64 on my machine too, but it still fails. It's possible something to do with np.loadtext because loading with load_svmlight_file passes the test. |
@guolinke still fail if I init dataset with file path string. |
@wxchan I can pass these tests except multi-class in my local machine. |
@wxchan refer to the test result: https://travis-ci.org/Microsoft/LightGBM/jobs/292447965 |
@wxchan I don't know why these tests are still failed: https://travis-ci.org/Microsoft/LightGBM/jobs/292509708 they all pass in my local machine |
@guolinke how about giving some tolerances of inequality? I think both results are reasonable? |
@wxchan I think we can check the model, instead of the prediction result |
@guolinke then we can't check consistency of prediction code. |
@wxchan we can check it by using the same model. I remember python-package can predict from file, which calls the same function of cpp. |
@guolinke I tried that, strangely can't pass tests too. |
still the float point issue? did you try the std::atof? |
@wxchan I think my PR on your branch should pass the tests. |
* update atof * fix bug * fix tests. * fix bug * fix dtypes * fix categorical feature override * fix protobuf on vs build (microsoft#1004) * [optional] support protobuf * fix windows/LightGBM.vcxproj * add doc * fix doc * fix vs support (#2) * fix vs support * fix cmake * fix microsoft#1012 * [python] add network config api (microsoft#1019) * add network * update doc * add float tolerance in bin finder. * fix a bug * update tests * add double torelance on tree model * fix tests * simplify the double comparison * fix lightsvm zero base * move double tolerance to the bin finder. * fix pylint
@wxchan I think that setting any parameter's default value to To speak about |
@StrikerRUS it makes no difference. The difference now is, the seed in native api has no default value, it will use c++ default *_seed; sklearn api has a default seed=0, so those *_seed will be set to some other values. I think users just want reproducible behavior by using seed, they just need to know it's fixed result or random. |
speak of this, a totally different subject: there was a feature request about supporting numpy RandomState for random_state, I think it's unnecessary and didn't have a good idea for it, perhaps we can support it if it's simple. #730 |
@wxchan My first paragraph of comment was more about Your idea about ignoring
|
@StrikerRUS how about just delete it from |
@wxchan I think it'll be confusing: |
@@ -555,8 +555,8 @@ def __pred_for_csc(self, csc, num_iteration, predict_type): | |||
|
|||
class Dataset(object): | |||
"""Dataset in LightGBM.""" | |||
def __init__(self, data, label=None, max_bin=255, reference=None, | |||
weight=None, group=None, silent=False, | |||
def __init__(self, data, label=None, max_bin=None, reference=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I ask why you've changed max_bin
to None
in public interface when it's actually still 255
? I wrote in my previous comment about such cases that they're confusing. If you worry about you'll miss some places while changing the default value in Parameters.rst, just search GitHub with param=old_value
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's set by @guolinke
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@StrikerRUS This is to solve problem of the parameter priority. User can set max_bin
(and other parameters) in both the parameter dict and the function arguments. This will cause the problem: we don't know which one is high "priority" when user set it in both two places. As a result, we can set the default function argument to None. If user didn't set the function argument, we use the value in parameter dict, otherwise use the function arguments.
We can add something like defualt=None (255 in c_api)
in python doc, to avoid the addiction search of that parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guolinke
I suppose it's obvious for users that function argument shouldn't be duplicated in param dict and parameter in signature which has the default value and the own description has higher priority than parameter in dict.
Maybe than it's better to completely remove max_been
from arguments (for 1 or 2 release mark as deprecated)? Because it's oddly that None
actually means 255
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some users like to put all parameters into dicts( like me), some like to put them into function arguments. I think set default to None is reasonable, since it is consistent with CLI version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove them from arguments as well
python-package/lightgbm/VERSION.txt
Outdated
@@ -0,0 +1 @@ | |||
2.0.10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What for do we need the duplicate of this?
https://github.com/Microsoft/LightGBM/blob/master/VERSION.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I add it to git accidentally
the gpu test fails. is there some parameter inconsistency? |
@wxchan Maybe because of this?
|
@wxchan maybe you can try run gpu by python two times, and check the consistency. And they are not the same, we can remove the consistency in GPU test. |
Fixed by gpu_use_dp=true. @guolinke @StrikerRUS |
@@ -633,7 +636,8 @@ def _lazy_init(self, data, label=None, max_bin=255, reference=None, | |||
params = {} if params is None else params | |||
self.max_bin = max_bin | |||
self.predictor = predictor | |||
params["max_bin"] = max_bin | |||
if self.max_bin is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wxchan Please add deprecation warning here.
StrikerRUS 23 hours ago Collaborator
Maybe than it's better to completely remove max_been from arguments (for 1 or 2 release mark as deprecated)? Because it's oddly that None actually means 255...
guolinke an hour ago Member
I think we can remove them from arguments as well
I am outside. If there are no other issues, can we merge this first and fix it in following commit? @guolinke @StrikerRUS |
@wxchan sure. |
@guolinke merge this now? |
@guolinke my new added test cases always fail. Can you help check where goes wrong?