Skip to content

boxhed_.hazard() fails with "XGBoostError: std::bad_alloc" #3

@pundumx

Description

@pundumx

I trained a model; saved it with dump_model(); loaded it in a new notebook with load_model(); and passed test data with hazard(). That call failed with "XGBoostError: std::bad_alloc"; full traceback follows. What should I be checking? (Do I correctly infer that boxhed calls its own XGBoost code from site-packages/boxhed_kernel/lib/libboxhed_kernel.so?)

---------------------------------------------------------------------------
XGBoostError                              Traceback (most recent call last)
/tmp/ipykernel_347974/1029529565.py in <module>
----> 1 haz_vals = boxhed_.hazard(df)
      2 haz_vals

/jupyterhub/anaconda3/lib/python3.9/site-packages/boxhed/boxhed.py in hazard(self, X, ntree_limit)
    261         X = check_array(X, force_all_finite='allow-nan')
    262 
--> 263         return self.boxhed_.predict(self._X_y_to_dmat(X), ntree_limit = ntree_limit)
    264 
    265     def _get_survival(self, X, t, ntree_limit = 0):

/jupyterhub/anaconda3/lib/python3.9/site-packages/boxhed/boxhed.py in _X_y_to_dmat(self, X, y, w)
     72         if not hasattr(self, 'X_colnames'):
     73             self.X_colnames = None #model probably created for CV, no need for data name matching
---> 74         dmat = xgb.DMatrix(pd.DataFrame(X, columns=self.X_colnames))
     75 
     76         if (y is not None):

/jupyterhub/anaconda3/lib/python3.9/site-packages/boxhed_kernel/core.py in __init__(self, data, label, weight, base_margin, missing, silent, feature_names, feature_types, nthread, enable_categorical)
    497 
    498         from .data import dispatch_data_backend
--> 499         handle, feature_names, feature_types = dispatch_data_backend(
    500             data, missing=self.missing,
    501             threads=self.nthread,

/jupyterhub/anaconda3/lib/python3.9/site-packages/boxhed_kernel/data.py in dispatch_data_backend(data, missing, threads, feature_names, feature_types, enable_categorical)
    536         return _from_tuple(data, missing, feature_names, feature_types)
    537     if _is_pandas_df(data):
--> 538         return _from_pandas_df(data, enable_categorical, missing, threads,
    539                                feature_names, feature_types)
    540     if _is_pandas_series(data):

/jupyterhub/anaconda3/lib/python3.9/site-packages/boxhed_kernel/data.py in _from_pandas_df(data, enable_categorical, missing, nthread, feature_names, feature_types)
    242     data, feature_names, feature_types = _transform_pandas_df(
    243         data, enable_categorical, feature_names, feature_types)
--> 244     return _from_numpy_array(data, missing, nthread, feature_names,
    245                              feature_types)
    246 

/jupyterhub/anaconda3/lib/python3.9/site-packages/boxhed_kernel/data.py in _from_numpy_array(data, missing, nthread, feature_names, feature_types)
    145     flatten = _transform_np_array(data)
    146     handle = ctypes.c_void_p()
--> 147     _check_call(_LIB.XGDMatrixCreateFromMat_omp(
    148         flatten.ctypes.data_as(ctypes.POINTER(ctypes.c_float)),
    149         c_bst_ulong(data.shape[0]),

/jupyterhub/anaconda3/lib/python3.9/site-packages/boxhed_kernel/core.py in _check_call(ret)
    186     """
    187     if ret != 0:
--> 188         raise XGBoostError(py_str(_LIB.XGBGetLastError()))
    189 
    190 

XGBoostError: std::bad_alloc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions