Unverified Commit 97ece148 authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[R-package] use as.factor() instead of factor() in lgb.cv() (#3560)

* [R-package] use as.factor() instead of factor() in lgb.cv()

* comment out CIs

* Revert "comment out CIs"

This reverts commit fabaf9a92b7c3df4ed0fdd8d67cbc85a2fb18f47.

* empty commit
parent efa9ecf8
......@@ -445,7 +445,7 @@ generate.cv.folds <- function(nfold, nrows, stratified, label, group, params) {
if (isTRUE(stratified) && params$objective %in% c("binary", "multiclass") && length(label) == length(rnd_idx)) {
y <- label[rnd_idx]
y <- factor(y)
y <- as.factor(y)
folds <- lgb.stratified.folds(y, nfold)
} else {
......@@ -495,7 +495,7 @@ generate.cv.folds <- function(nfold, nrows, stratified, label, group, params) {
}
# Creates CV folds stratified by the values of y.
# It was borrowed from caret::lgb.stratified.folds and simplified
# It was borrowed from caret::createFolds and simplified
# by always returning an unnamed list of fold indices.
#' @importFrom stats quantile
lgb.stratified.folds <- function(y, k = 10L) {
......@@ -529,7 +529,7 @@ lgb.stratified.folds <- function(y, k = 10L) {
## Reset levels so that the possible levels and
## the levels in the vector are the same
y <- factor(as.character(y))
y <- as.factor(as.character(y))
numInClass <- table(y)
foldVector <- vector(mode = "integer", length(y))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment