Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
0c4bb89d
"vscode:/vscode.git/clone" did not exist on "c10b0430b8f13d399f4191d09caec3e2332fc73f"
Unverified
Commit
0c4bb89d
authored
Nov 26, 2018
by
Guolin Ke
Committed by
GitHub
Nov 26, 2018
Browse files
fix bug for one-class binary (#1877)
parent
e55c8158
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
src/objective/binary_objective.hpp
src/objective/binary_objective.hpp
+7
-2
No files found.
src/objective/binary_objective.hpp
View file @
0c4bb89d
...
...
@@ -65,10 +65,11 @@ public:
++
cnt_negative
;
}
}
need_train_
=
true
;
if
(
cnt_negative
==
0
||
cnt_positive
==
0
)
{
Log
::
Warning
(
"Contains only one class"
);
// not need to boost.
n
um_data_
=
0
;
n
eed_train_
=
false
;
}
Log
::
Info
(
"Number of positive: %d, number of negative: %d"
,
cnt_positive
,
cnt_negative
);
// use -1 for negative class, and 1 for positive class
...
...
@@ -91,6 +92,9 @@ public:
}
void
GetGradients
(
const
double
*
score
,
score_t
*
gradients
,
score_t
*
hessians
)
const
override
{
if
(
!
need_train_
)
{
return
;
}
if
(
weights_
==
nullptr
)
{
#pragma omp parallel for schedule(static)
for
(
data_size_t
i
=
0
;
i
<
num_data_
;
++
i
)
{
...
...
@@ -146,7 +150,7 @@ public:
}
bool
ClassNeedTrain
(
int
/*class_id*/
)
const
override
{
return
n
um_data_
>
0
;
return
n
eed_train_
;
}
const
char
*
GetName
()
const
override
{
...
...
@@ -185,6 +189,7 @@ private:
const
label_t
*
weights_
;
double
scale_pos_weight_
;
std
::
function
<
bool
(
label_t
)
>
is_pos_
;
bool
need_train_
;
};
}
// namespace LightGBM
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment