py: replace attr_names() with attributes()
This commit is contained in:
parent
26b36714ea
commit
ffed95eec0
@ -709,20 +709,21 @@ class Booster(object):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def attr_names(self):
|
def attributes(self):
|
||||||
"""Get the names of attributes stored in the Booster.
|
"""Get attributes stored in the Booster as a dictionary.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
value : list of strings
|
result : dictionary of attribute_name: attribute_value pairs of strings.
|
||||||
Returns an empty list if there's no attributes.
|
Returns an empty dict if there's no attributes.
|
||||||
"""
|
"""
|
||||||
length = ctypes.c_ulong()
|
length = ctypes.c_ulong()
|
||||||
sarr = ctypes.POINTER(ctypes.c_char_p)()
|
sarr = ctypes.POINTER(ctypes.c_char_p)()
|
||||||
_check_call(_LIB.XGBoosterGetAttrNames(self.handle,
|
_check_call(_LIB.XGBoosterGetAttrNames(self.handle,
|
||||||
ctypes.byref(length),
|
ctypes.byref(length),
|
||||||
ctypes.byref(sarr)))
|
ctypes.byref(sarr)))
|
||||||
res = from_cstr_to_pystr(sarr, length)
|
attr_names = from_cstr_to_pystr(sarr, length)
|
||||||
|
res = {n: self.attr(n) for n in attr_names}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def set_attr(self, **kwargs):
|
def set_attr(self, **kwargs):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user