| 264 | } |
| 265 | |
| 266 | void 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 | |
| 292 | void TestCoxRegressionGPair(const Context* ctx) { |
| 293 | std::vector<std::pair<std::string, std::string>> args; |
no test coverage detected