xgboost_wrapper

class coffea.ml_tools.xgboost_wrapper(fname)[source]

Bases: numpy_call_wrapper, nonserializable_attribute

Very simple wrapper for xgbooster inference. The xgboost.Booster object is nonserializable, so the users should pass in the xgboost model file.

Methods Summary

numpy_call(data[, dmat_args, predict_args])

Passing the numpy array data as-is to the construction of an xgboost.DMatrix constructor (with additional keyword arguments should they be specified), the run the xgboost.Booster.predict method (with additional keyword arguments).

validate_numpy_input(data[, dmat_args, ...])

The inner most dimension of the data array should be smaller than the number of features of the xgboost model.

Methods Documentation

numpy_call(data: ndarray, dmat_args: Dict | None = None, predict_args: Dict | None = None)[source]

Passing the numpy array data as-is to the construction of an xgboost.DMatrix constructor (with additional keyword arguments should they be specified), the run the xgboost.Booster.predict method (with additional keyword arguments).

validate_numpy_input(data: ndarray, dmat_args: Dict | None = None, predict_args: Dict | None = None)[source]

The inner most dimension of the data array should be smaller than the number of features of the xgboost model. (Will raise a warning if mismatched). We will not attempt to parse the kwargs passed to the construction of a DMatrix, or the predict call, as those advanced features are expected to be properly handled by the user.