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

Function TestSoftprobMultiClassBasic

tests/cpp/objective/test_multiclass_obj.cc:57–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57void TestSoftprobMultiClassBasic(const Context* ctx) {
58 std::vector<std::pair<std::string, std::string>> args {
59 std::pair<std::string, std::string>("num_class", "3")};
60
61 std::unique_ptr<ObjFunction> obj {
62 ObjFunction::Create("multi:softprob", ctx)
63 };
64 obj->Configure(args);
65 CheckConfigReload(obj, "multi:softprob");
66
67 HostDeviceVector<bst_float> io_preds = {2.0f, 0.0f, 1.0f};
68 std::vector<bst_float> out_preds = {0.66524096f, 0.09003057f, 0.24472847f};
69
70 obj->PredTransform(&io_preds);
71 auto& preds = io_preds.HostVector();
72
73 for (int i = 0; i < static_cast<int>(io_preds.Size()); ++i) {
74 EXPECT_NEAR(preds[i], out_preds[i], 0.01f);
75 }
76}
77
78} // namespace xgboost

Callers 2

TESTFunction · 0.85
TESTFunction · 0.85

Calls 4

CheckConfigReloadFunction · 0.85
ConfigureMethod · 0.45
PredTransformMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected