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

Add check for base_score in _get_attributes function #626

Closed
wants to merge 1 commit into from

Conversation

tolleybot
Copy link
Contributor

In the _get_attributes function in xgboost/_parse.py, I've added a check for the base_score attribute. This change is necessary because base_score can sometimes be stored as a string, which can cause issues in subsequent computations that expect it to be a float.

The updated code now checks if base_score is not in kwargs and, if not, sets it to 0.5. If base_score is in kwargs and is a string, it converts it to a float.

Here's the updated code:

if 'base_score' not in kwargs: kwargs['base_score'] = 0.5 elif isinstance(kwargs['base_score'], str): kwargs['base_score'] = float(kwargs['base_score']) return kwargs

This change ensures that base_score is always a float, which should prevent potential type-related errors in the future.

@xadupre
Copy link
Collaborator

xadupre commented Aug 1, 2023

Closed, replaced by #637.

@xadupre xadupre closed this Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants