| 166 | } |
| 167 | |
| 168 | void TestPoissonRegressionBasic(const Context* ctx) { |
| 169 | std::vector<std::pair<std::string, std::string>> args; |
| 170 | std::unique_ptr<ObjFunction> obj{ObjFunction::Create("count:poisson", ctx)}; |
| 171 | |
| 172 | obj->Configure(args); |
| 173 | CheckConfigReload(obj, "count:poisson"); |
| 174 | |
| 175 | // test label validation |
| 176 | EXPECT_ANY_THROW(CheckObjFunction(obj, {0}, {-1}, {1}, {0}, {0})) |
| 177 | << "Expected error when label < 0 for PoissonRegression"; |
| 178 | |
| 179 | // test ProbToMargin |
| 180 | CheckProbaToMargin(obj, 0.1f, -2.30f); |
| 181 | CheckProbaToMargin(obj, 0.5f, -0.69f); |
| 182 | CheckProbaToMargin(obj, 0.9f, -0.10f); |
| 183 | |
| 184 | // test PredTransform |
| 185 | HostDeviceVector<bst_float> io_preds = {0, 0.1f, 0.5f, 0.9f, 1}; |
| 186 | std::vector<bst_float> out_preds = {1, 1.10f, 1.64f, 2.45f, 2.71f}; |
| 187 | obj->PredTransform(&io_preds); |
| 188 | auto& preds = io_preds.HostVector(); |
| 189 | for (int i = 0; i < static_cast<int>(io_preds.Size()); ++i) { |
| 190 | EXPECT_NEAR(preds[i], out_preds[i], 0.01f); |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | void TestGammaRegressionGPair(const Context* ctx) { |
| 195 | std::vector<std::pair<std::string, std::string>> args; |
no test coverage detected