Use bst_float consistently throughout (#1824)
* Fix various typos * Add override to functions that are overridden gcc gives warnings about functions that are being overridden by not being marked as oveirridden. This fixes it. * Use bst_float consistently Use bst_float for all the variables that involve weight, leaf value, gradient, hessian, gain, loss_chg, predictions, base_margin, feature values. In some cases, when due to additions and so on the value can take a larger value, double is used. This ensures that type conversions are minimal and reduces loss of precision.
This commit is contained in:
@@ -64,7 +64,7 @@ try:
|
||||
except ImportError:
|
||||
SKLEARN_INSTALLED = False
|
||||
|
||||
# used for compatiblity without sklearn
|
||||
# used for compatibility without sklearn
|
||||
XGBModelBase = object
|
||||
XGBClassifierBase = object
|
||||
XGBRegressorBase = object
|
||||
|
||||
@@ -19,7 +19,7 @@ from .compat import STRING_TYPES, PY3, DataFrame, py_str, PANDAS_INSTALLED
|
||||
|
||||
|
||||
class XGBoostError(Exception):
|
||||
"""Error throwed by xgboost trainer."""
|
||||
"""Error thrown by xgboost trainer."""
|
||||
pass
|
||||
|
||||
|
||||
@@ -387,7 +387,7 @@ class DMatrix(object):
|
||||
The field name of the information
|
||||
|
||||
data: numpy array
|
||||
The array ofdata to be set
|
||||
The array of data to be set
|
||||
"""
|
||||
_check_call(_LIB.XGDMatrixSetFloatInfo(self.handle,
|
||||
c_str(field),
|
||||
@@ -403,7 +403,7 @@ class DMatrix(object):
|
||||
The field name of the information
|
||||
|
||||
data: numpy array
|
||||
The array ofdata to be set
|
||||
The array of data to be set
|
||||
"""
|
||||
_check_call(_LIB.XGDMatrixSetUIntInfo(self.handle,
|
||||
c_str(field),
|
||||
@@ -980,11 +980,11 @@ class Booster(object):
|
||||
|
||||
def save_raw(self):
|
||||
"""
|
||||
Save the model to a in memory buffer represetation
|
||||
Save the model to a in memory buffer representation
|
||||
|
||||
Returns
|
||||
-------
|
||||
a in memory buffer represetation of the model
|
||||
a in memory buffer representation of the model
|
||||
"""
|
||||
length = ctypes.c_ulong()
|
||||
cptr = ctypes.POINTER(ctypes.c_char)()
|
||||
|
||||
@@ -7,7 +7,7 @@ import sys
|
||||
|
||||
|
||||
class XGBoostLibraryNotFound(Exception):
|
||||
"""Error throwed by when xgboost is not found"""
|
||||
"""Error thrown by when xgboost is not found"""
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ def to_graphviz(booster, num_trees=0, rankdir='UT',
|
||||
yes_color='#0000FF', no_color='#FF0000', **kwargs):
|
||||
|
||||
"""Convert specified tree to graphviz instance. IPython can automatically plot the
|
||||
returned graphiz instance. Otherwise, you shoud call .render() method
|
||||
returned graphiz instance. Otherwise, you should call .render() method
|
||||
of the returned graphiz instance.
|
||||
|
||||
Parameters
|
||||
@@ -169,9 +169,9 @@ def to_graphviz(booster, num_trees=0, rankdir='UT',
|
||||
rankdir : str, default "UT"
|
||||
Passed to graphiz via graph_attr
|
||||
yes_color : str, default '#0000FF'
|
||||
Edge color when meets the node condigion.
|
||||
Edge color when meets the node condition.
|
||||
no_color : str, default '#FF0000'
|
||||
Edge color when doesn't meet the node condigion.
|
||||
Edge color when doesn't meet the node condition.
|
||||
kwargs :
|
||||
Other keywords passed to graphviz graph_attr
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ from .compat import pickle
|
||||
|
||||
|
||||
def _init_rabit():
|
||||
"""internal libary initializer."""
|
||||
"""internal library initializer."""
|
||||
if _LIB is not None:
|
||||
_LIB.RabitGetRank.restype = ctypes.c_int
|
||||
_LIB.RabitGetWorldSize.restype = ctypes.c_int
|
||||
@@ -21,7 +21,7 @@ def _init_rabit():
|
||||
|
||||
|
||||
def init(args=None):
|
||||
"""Initialize the rabit libary with arguments"""
|
||||
"""Initialize the rabit library with arguments"""
|
||||
if args is None:
|
||||
args = []
|
||||
arr = (ctypes.c_char_p * len(args))()
|
||||
@@ -156,7 +156,7 @@ def allreduce(data, op, prepare_fun=None):
|
||||
Reduction operators, can be MIN, MAX, SUM, BITOR
|
||||
prepare_fun: function
|
||||
Lazy preprocessing function, if it is not None, prepare_fun(data)
|
||||
will be called by the function before performing allreduce, to intialize the data
|
||||
will be called by the function before performing allreduce, to initialize the data
|
||||
If the result of Allreduce can be recovered directly,
|
||||
then prepare_fun will NOT be called
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ class XGBModel(XGBModelBase):
|
||||
self._Booster = None
|
||||
|
||||
def __setstate__(self, state):
|
||||
# backward compatiblity code
|
||||
# backward compatibility code
|
||||
# load booster from raw if it is raw
|
||||
# the booster now support pickle
|
||||
bst = state["_Booster"]
|
||||
|
||||
@@ -148,7 +148,7 @@ def train(params, dtrain, num_boost_round=10, evals=(), obj=None, feval=None,
|
||||
evals_result: dict
|
||||
This dictionary stores the evaluation results of all the items in watchlist.
|
||||
Example: with a watchlist containing [(dtest,'eval'), (dtrain,'train')] and
|
||||
a paramater containing ('eval_metric': 'logloss')
|
||||
a parameter containing ('eval_metric': 'logloss')
|
||||
Returns: {'train': {'logloss': ['0.48253', '0.35953']},
|
||||
'eval': {'logloss': ['0.480385', '0.357756']}}
|
||||
verbose_eval : bool or int
|
||||
@@ -291,7 +291,7 @@ def cv(params, dtrain, num_boost_round=10, nfold=3, stratified=False, folds=None
|
||||
fpreproc=None, as_pandas=True, verbose_eval=None, show_stdv=True,
|
||||
seed=0, callbacks=None):
|
||||
# pylint: disable = invalid-name
|
||||
"""Cross-validation with given paramaters.
|
||||
"""Cross-validation with given parameters.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
||||
Reference in New Issue
Block a user