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

More functionality for model attributes #1198

Merged
merged 6 commits into from May 16, 2016
Merged

Conversation

khotilov
Copy link
Member

  • Learner and C-api: added a method to retrieve the names of available attributes
  • Learner and C-api: added ability to delete an attribute (C-api uses the "setting null value means delete" idiom; Learner gets a separate method for delete, since I didn't want to change its setter interface)
  • R: getters and setters for xgboost attributes
  • R: separate function to set xgboost parameters
  • R: in xgb.Booster constructor, when both modelfile and params are provided, set params after loading from modelfile
  • python: added attr_names() method; calling set_attr(a = Null) would delete an attribute

Let me know if "setting null value means delete" is not acceptable for C or Python interface. I can add separate attr deletion methods.

ctypes.byref(length),
ctypes.byref(sarr)))
res = from_cstr_to_pystr(sarr, length)
return res
Copy link
Member

Choose a reason for hiding this comment

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

how can it become list of strings?

Copy link
Member

Choose a reason for hiding this comment

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

no problem, I mistunderstand the function from_cstr_to_pystr

@tqchen
Copy link
Member

tqchen commented May 15, 2016

Thanks for the changes. It LGTM. We might want to make python API consistent with R's, i.e.

remove get_attr_names, but directly provides a attributes function that returns a dict of name->value

@khotilov
Copy link
Member Author

Done.

Note that Python's attributes() returns {} when no attributes while in R it would return NULL. In R I did it so it acts similar to R's native attributes() function. However, I feel that in Python it is more natural to use empty [] or {}, as it usually saves checking for None. It you want it to return None - no problem - I can change to that.

@tqchen tqchen merged commit 49bbd72 into dmlc:master May 16, 2016
@tqchen
Copy link
Member

tqchen commented May 16, 2016

This sounds good to me, thanks!

@tqchen tqchen mentioned this pull request Jul 29, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants