Skip to content
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

[python] Fix training on subset constructed without params #5213

Merged
merged 4 commits into from
May 24, 2022

Conversation

StrikerRUS
Copy link
Collaborator

Fixed #5170.

Formally, we change the signature of the public get_params() method in this PR: it returns an empty dict instead of None. But I'm not sure about marking this PR a breaking change because previously this method could return empty dicts as well.

@StrikerRUS StrikerRUS added the fix label May 15, 2022
@StrikerRUS StrikerRUS marked this pull request as ready for review May 15, 2022 01:34
Copy link
Collaborator

@jmoralez jmoralez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. After this change it's probably safe to change this function

def param_dict_to_str(data):
"""Convert Python dictionary to string, which is passed to C API."""
if data is None or not data:
return ""
to remove the case for None.

Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

I left one very very minor suggestion, but marking "approve" so you can merge immediately after addressing it if you agree.

python-package/lightgbm/basic.py Show resolved Hide resolved
@StrikerRUS
Copy link
Collaborator Author

@jmoralez

After this change it's probably safe to change this function

Hmm, are you sure in this?
param_dict_to_str() is used to convert parameters in many places of the codebase. While in most cases before those lines we have something like this

params = {} if params is None else deepcopy(params)

there is no guarantee we haven't forgotten to do such None -> {} replacement somewhere. I think it's better to leave that explicit None handling in param_dict_to_str().

@StrikerRUS StrikerRUS merged commit a4478f7 into master May 24, 2022
@StrikerRUS StrikerRUS deleted the fix_subset branch May 24, 2022 00:45
@jameslamb jameslamb mentioned this pull request Oct 7, 2022
40 tasks
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lgb.train() encountering TypeError: 'NoneType' object is not iterable
3 participants