Skip to content

Commit

Permalink
seq(length=)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico authored Apr 22, 2024
1 parent 6b4dd75 commit e44cea1
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/caret/R/classDist.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ classDist.default <- function(x, y, groups = 5,
if(is.numeric(y))
{
y <- cut(y,
unique(quantile(y, probs = seq(0, 1, length = groups + 1))),
unique(quantile(y, probs = seq(0, 1, length.out = groups + 1))),
include.lowest = TRUE)
classLabels <- paste(round((1:groups)/groups*100, 2))
y <- factor(y)
Expand Down
4 changes: 2 additions & 2 deletions pkg/caret/R/createDataPartition.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ createDataPartition <- function (y, times = 1, p = 0.5, list = TRUE, groups = mi

if(is.numeric(y)) {
y <- cut(y,
unique(quantile(y, probs = seq(0, 1, length = groups))),
unique(quantile(y, probs = seq(0, 1, length.out = groups))),
include.lowest = TRUE)
} else {
xtab <- table(y)
Expand Down Expand Up @@ -180,7 +180,7 @@ createDataPartition <- function (y, times = 1, p = 0.5, list = TRUE, groups = mi
cuts <- floor(length(y)/k)
if(cuts < 2) cuts <- 2
if(cuts > 5) cuts <- 5
breaks <- unique(quantile(y, probs = seq(0, 1, length = cuts)))
breaks <- unique(quantile(y, probs = seq(0, 1, length.out = cuts)))
y <- cut(y, breaks, include.lowest = TRUE)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/caret/R/gafs.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ ga_func_check <- function(x) {
#' @export gafs_initial
gafs_initial <- function (vars, popSize, ...) {
x <- matrix(NA, nrow = popSize, ncol = vars)
probs <- seq(.9, .1, length = popSize)
probs <- seq(.9, .1, length.out = popSize)
for(i in 1:popSize){
x[i,] <- sample(0:1, replace = TRUE,
size = vars,
Expand Down
2 changes: 1 addition & 1 deletion pkg/caret/R/lift.R
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ liftCalc <- function(x, class = levels(x$liftClassVar)[1], cuts = NULL) {
baseline <- mean(x$liftClassVar == class)
if(!is.null(cuts)) {
if(length(cuts) == 1) {
cuts <- rev(seq(0, 1, length = cuts))
cuts <- rev(seq(0, 1, length.out = cuts))
} else {
cuts <- unique(c(1, sort(cuts, decreasing = TRUE), 0))
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/caret/R/misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,10 @@ var_seq <- function(p, classification = FALSE, len = 3) {
} else {
if(p <= len)
{
tuneSeq <- floor(seq(2, to = p, length = p))
tuneSeq <- floor(seq(2, to = p, length.out = p))
} else {
if(p < 500 ) tuneSeq <- floor(seq(2, to = p, length = len))
else tuneSeq <- floor(2^seq(1, to = log(p, base = 2), length = len))
if(p < 500 ) tuneSeq <- floor(seq(2, to = p, length.out = len))
else tuneSeq <- floor(2^seq(1, to = log(p, base = 2), length.out = len))
}
}
if(any(table(tuneSeq) > 1)) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/caret/R/twoClassSim.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ twoClassSim <- function(n = 100,
2*sin(pi*tmpData$Nonlinear2* tmpData$Nonlinear3)

if(linearVars > 0) {
lin <- seq(10, 1, length = linearVars)/4
lin <- seq(10, 1, length.out = linearVars)/4
lin <- lin * rep(c(-1, 1), floor(linearVars)+1)[1:linearVars]
for(i in seq(along.with = lin)) lp <- lp + tmpData[, i+3]*lin[i]
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/caret/tests/testthat/test_resamples.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test_that('resample calculations', {

test_that('test group-k-fold', {
get_data <- function(n = 500) {
prevalence <- seq(.1, .9, length = 26)
prevalence <- seq(.1, .9, length.out = 26)
dat <- sample(letters, size = n, replace = TRUE, prob = sample(prevalence))
data.frame(grp = dat, stringsAsFactors = TRUE)
}
Expand Down

0 comments on commit e44cea1

Please sign in to comment.