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

Function TestPoissonRegressionBasic

tests/cpp/objective/test_regression_obj.cc:168–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168void 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
194void TestGammaRegressionGPair(const Context* ctx) {
195 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