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
95f213bd
Commit
95f213bd
authored
Sep 08, 2017
by
Laurae
Committed by
Guolin Ke
Sep 08, 2017
Browse files
Add binary/classification requirement for strata (#897)
parent
de51990e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
R-package/R/lgb.cv.R
R-package/R/lgb.cv.R
+2
-1
No files found.
R-package/R/lgb.cv.R
View file @
95f213bd
...
@@ -323,7 +323,7 @@ generate.cv.folds <- function(nfold, nrows, stratified, label, group, params) {
...
@@ -323,7 +323,7 @@ generate.cv.folds <- function(nfold, nrows, stratified, label, group, params) {
rnd_idx
<-
sample
(
seq_len
(
nrows
))
rnd_idx
<-
sample
(
seq_len
(
nrows
))
# Request stratified folds
# Request stratified folds
if
(
isTRUE
(
stratified
)
&&
length
(
label
)
==
length
(
rnd_idx
))
{
if
(
isTRUE
(
stratified
)
&&
params
$
objective
%in%
c
(
"binary"
,
"multiclass"
)
&&
length
(
label
)
==
length
(
rnd_idx
))
{
y
<-
label
[
rnd_idx
]
y
<-
label
[
rnd_idx
]
y
<-
factor
(
y
)
y
<-
factor
(
y
)
...
@@ -400,6 +400,7 @@ lgb.stratified.folds <- function(y, k = 10) {
...
@@ -400,6 +400,7 @@ lgb.stratified.folds <- function(y, k = 10) {
}
}
if
(
k
<
length
(
y
))
{
if
(
k
<
length
(
y
))
{
## Reset levels so that the possible levels and
## Reset levels so that the possible levels and
## the levels in the vector are the same
## the levels in the vector are the same
y
<-
factor
(
as.character
(
y
))
y
<-
factor
(
as.character
(
y
))
...
...
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