MCPcopy Create free account
hub / github.com/dmlc/xgboost / TestTweedieRegressionBasic

Function TestTweedieRegressionBasic

tests/cpp/objective/test_regression_obj.cc:266–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264}
265
266void TestTweedieRegressionBasic(const Context* ctx) {
267 std::vector<std::pair<std::string, std::string>> args;
268 std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:tweedie", ctx)};
269
270 obj->Configure(args);
271 CheckConfigReload(obj, "reg:tweedie");
272
273 // test label validation
274 EXPECT_ANY_THROW(CheckObjFunction(obj, {0}, {-1}, {1}, {0}, {0}))
275 << "Expected error when label < 0 for TweedieRegression";
276
277 // test ProbToMargin
278 CheckProbaToMargin(obj, 0.1f, -2.30f);
279 CheckProbaToMargin(obj, 0.5f, -0.69f);
280 CheckProbaToMargin(obj, 0.9f, -0.10f);
281
282 // test PredTransform
283 HostDeviceVector<bst_float> io_preds = {0, 0.1f, 0.5f, 0.9f, 1};
284 std::vector<bst_float> out_preds = {1, 1.10f, 1.64f, 2.45f, 2.71f};
285 obj->PredTransform(&io_preds);
286 auto& preds = io_preds.HostVector();
287 for (int i = 0; i < static_cast<int>(io_preds.Size()); ++i) {
288 EXPECT_NEAR(preds[i], out_preds[i], 0.01f);
289 }
290}
291
292void TestCoxRegressionGPair(const Context* ctx) {
293 std::vector<std::pair<std::string, std::string>> args;

Callers 2

TESTFunction · 0.85
TESTFunction · 0.85

Calls 6

CheckConfigReloadFunction · 0.85
CheckObjFunctionFunction · 0.85
CheckProbaToMarginFunction · 0.85
ConfigureMethod · 0.45
PredTransformMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected