Implementation of hinge loss for binary classification (#3477)
This commit is contained in:
committed by
Rory Mitchell
parent
44811f2330
commit
69454d9487
20
tests/cpp/objective/test_hinge.cc
Normal file
20
tests/cpp/objective/test_hinge.cc
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright by Contributors
|
||||
#include <xgboost/objective.h>
|
||||
#include <limits>
|
||||
|
||||
#include "../helpers.h"
|
||||
|
||||
TEST(Objective, HingeObj) {
|
||||
xgboost::ObjFunction * obj = xgboost::ObjFunction::Create("binary:hinge");
|
||||
std::vector<std::pair<std::string, std::string> > args;
|
||||
obj->Configure(args);
|
||||
xgboost::bst_float eps = std::numeric_limits<xgboost::bst_float>::min();
|
||||
CheckObjFunction(obj,
|
||||
{-1.0f, -0.5f, 0.5f, 1.0f, -1.0f, -0.5f, 0.5f, 1.0f},
|
||||
{ 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f},
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f},
|
||||
{ 0.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, 0.0f},
|
||||
{ eps, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, eps });
|
||||
|
||||
ASSERT_NO_THROW(obj->DefaultEvalMetric());
|
||||
}
|
||||
Reference in New Issue
Block a user