def test_callback_list(self): X, y = tm.get_boston() m = xgb.DMatrix(X, y) callbacks = [xgb.callback.EarlyStopping(rounds=10)] for i in range(4): xgb.train({'objective': 'reg:squarederror', 'eval_metric': 'rmse'}, m, evals=[(m, 'Train')], num_boost_round=1, verbose_eval=True, callbacks=callbacks) assert len(callbacks) == 1
def test_gpu_coordinate_from_cupy(self): # Training linear model is quite expensive, so we don't include it in # test_from_cupy.py import cupy params = {'booster': 'gblinear', 'updater': 'gpu_coord_descent', 'n_estimators': 100} X, y = tm.get_boston() cpu_model = xgb.XGBRegressor(**params) cpu_model.fit(X, y) cpu_predt = cpu_model.predict(X) X = cupy.array(X) y = cupy.array(y) gpu_model = xgb.XGBRegressor(**params) gpu_model.fit(X, y) gpu_predt = gpu_model.predict(X) cupy.testing.assert_allclose(cpu_predt, gpu_predt)