Skip to content

Commit

Permalink
removed calls from some objects
Browse files Browse the repository at this point in the history
  • Loading branch information
topepo committed Jan 28, 2015
1 parent c29d5aa commit dfda220
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 23 deletions.
1 change: 0 additions & 1 deletion pkg/caret/R/avNNet.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ avNNet.formula <- function (formula, data, weights, ...,
...)
res$terms <- Terms
res$coefnames <- colnames(x)
res$call <- match.call()
res$na.action <- attr(m, "na.action")
res$contrasts <- cons
res$xlevels <- .getXlevels(Terms, m)
Expand Down
10 changes: 2 additions & 8 deletions pkg/caret/R/bagFDA.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ function(x, y, weights = NULL, B = 50, keepX = TRUE, ...)
{
requireNamespaceQuietStop("mda")
requireNamespaceQuietStop("earth")
funcCall <- match.call(expand.dots = TRUE)
if(!is.matrix(x)) x <- as.matrix(x)
if(!is.vector(y) & !is.factor(y)) y <- as.vector(y)
if(!is.vector(y) & !is.factor(y)) y <- factor(y[,1])
Expand Down Expand Up @@ -40,13 +39,12 @@ function(x, y, weights = NULL, B = 50, keepX = TRUE, ...)
oob <- matrix(unlist(oobList), ncol = length(oobList[[1]]), byrow = TRUE)
colnames(oob) <- names(oobList[[1]])
if(keepX) x <- x else x <- NULL
structure(list(fit = btFits, B = B, oob = oob, call = funcCall, x = x, levels = levels(y), dots = list(...)), class = "bagFDA")
structure(list(fit = btFits, B = B, oob = oob, x = x, levels = levels(y), dots = list(...)), class = "bagFDA")
}

"bagFDA.formula" <-
function (formula, data = NULL, B = 50, keepX = TRUE, ..., subset, weights, na.action = na.omit)
{
funcCall <- match.call(expand.dots = TRUE)

if (!inherits(formula, "formula"))
stop("method is only for formula objects")
Expand All @@ -67,15 +65,13 @@ function (formula, data = NULL, B = 50, keepX = TRUE, ..., subset, weights, na.a
if (xint > 0) x <- x[, -xint, drop = FALSE]

out <- bagFDA.default(x, y, w, B = B, keepX = keepX, ...)
out$call <- funcCall
out
}


"print.bagFDA" <-
function (x, ...)
{
cat("\nCall:\n", deparse(x$call), "\n\n", sep = "")
if(!is.null(x$x))cat("Data:\n # variables:\t", dim(x$x)[2], "\n # samples:\t", dim(x$x)[1], "\n")
cat(
"\nModel:",
Expand Down Expand Up @@ -152,16 +148,14 @@ function(object, ...)
}))
modelInfo <- cbind(numTerms, numVar)
colnames(modelInfo) <- c("Num Terms", "Num Variables")
out <- list(modelInfo = modelInfo, oobStat = oobStat, bagMARSCall = object$call)
out <- list(modelInfo = modelInfo, oobStat = oobStat)
class(out) <- "summary.bagFDA"
out
}

"print.summary.bagFDA" <-
function(x, digits = max(3, getOption("digits") - 3), ...)
{
cat("\nCall:\n", deparse(x$bagMARSCall), "\n\n", sep = "")

oobStat <- apply(x$oob, 2, function(x) quantile(x, probs = c(0, 0.025, .25, .5, .75, .975, 1)))
cat("Out of bag statistics:\n\n")
print(x$oobStat, digits = digits)
Expand Down
1 change: 0 additions & 1 deletion pkg/caret/R/icr.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ icr.formula <- function (formula, data, weights, ...,
res <- icr.default(x, y, weights = w, thresh = thresh, ...)
res$terms <- Terms
res$coefnames <- colnames(x)
res$call <- match.call()
res$na.action <- attr(m, "na.action")
res$contrasts <- cons
res$xlevels <- .getXlevels(Terms, m)
Expand Down
7 changes: 1 addition & 6 deletions pkg/caret/R/knn3.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ knn3.default <- function(x, ...)

knn3.formula <- function (formula, data, subset, na.action, k = 5, ...)
{
cl <- match.call()

if (missing(formula) ||
(length(formula) != 3) ||
(length(attr(terms(formula[-2], data = data), "term.labels")) < 1) ||
Expand Down Expand Up @@ -36,7 +36,6 @@ knn3.formula <- function (formula, data, subset, na.action, k = 5, ...)
RET <- list(learn = list(y = y, X = x))
RET$k <- k
RET$terms <- Terms
RET$call <- match.call(expand.dots = TRUE)
RET$contrasts <- attr(x, "contrasts")
RET$xlevels <- xlev
RET$theDots <- list(...)
Expand All @@ -51,8 +50,6 @@ knn3.data.frame <- function(x, y, k = 5, ...)
{
x <- as.matrix(x)
out <- knn3(x, y = y, k = k, ...)
call <- match.call(expand.dots = TRUE)
out$call <- call
out
}

Expand All @@ -63,7 +60,6 @@ knn3.matrix <- function(x, y, k = 5, ...)
RET <- list(learn = list(y = y, X = x))
RET$k <- k
RET$terms <- NULL
RET$call <- match.call(expand.dots = TRUE)
RET$contrasts <- NULL
RET$xlevels <- NULL
RET$theDots <- list(...)
Expand All @@ -74,7 +70,6 @@ knn3.matrix <- function(x, y, k = 5, ...)
print.knn3 <- function (x, ...)
{
cat(x$k, "-nearest neighbor classification model\n", sep = "")
printCall(x$call)
cat("Training set class distribution:\n")
print(table(x$learn$y))

Expand Down
5 changes: 0 additions & 5 deletions pkg/caret/R/knnreg.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ knnreg.default <- function(x, ...)

knnreg.formula <- function (formula, data, subset, na.action, k = 5, ...)
{
cl <- match.call()
if (missing(formula) ||
(length(formula) != 3) ||
(length(attr(terms(formula[-2], data = data), "term.labels")) < 1) ||
Expand Down Expand Up @@ -36,7 +35,6 @@ knnreg.formula <- function (formula, data, subset, na.action, k = 5, ...)
RET <- list(learn = list(y = y, X = x))
RET$k <- k
RET$terms <- Terms
RET$call <- match.call(expand.dots = TRUE)
RET$contrasts <- attr(x, "contrasts")
RET$xlevels <- xlev
RET$theDots <- list(...)
Expand All @@ -54,7 +52,6 @@ knnreg.matrix <- function(x, y, k = 5, ...)
RET <- list(learn = list(y = y, X = x))
RET$k <- k
RET$terms <- NULL
RET$call <- match.call(expand.dots = TRUE)
RET$contrasts <- NULL
RET$theDots <- list(...)
class(RET) <- "knnreg"
Expand All @@ -69,7 +66,6 @@ knnreg.data.frame <- function(x, y, k = 5, ...)
RET <- list(learn = list(y = y, X = x))
RET$k <- k
RET$terms <- NULL
RET$call <- match.call(expand.dots = TRUE)
RET$contrasts <- NULL
RET$theDots <- list(...)
class(RET) <- "knnreg"
Expand All @@ -79,7 +75,6 @@ knnreg.data.frame <- function(x, y, k = 5, ...)
print.knnreg <- function (x, ...)
{
cat(x$k, "-nearest neighbor regression model\n", sep = "")
printCall(x$call)
invisible(x)
}

Expand Down
1 change: 0 additions & 1 deletion pkg/caret/R/pcaNNet.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ pcaNNet.formula <- function (formula, data, weights, ...,
res <- pcaNNet.default(x, y, weights = w, thresh = thresh, ...)
res$terms <- Terms
res$coefnames <- colnames(x)
res$call <- match.call()
res$na.action <- attr(m, "na.action")
res$contrasts <- cons
res$xlevels <- .getXlevels(Terms, m)
Expand Down
1 change: 0 additions & 1 deletion pkg/caret/R/plsda.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,5 @@ print.plsda <- function (x, ...) {
switch(x$probMethod,
softmax = cat("\nThe softmax function was used to compute class probabilities.\n"),
Bayes = cat("\nBayes rule was used to compute class probabilities.\n"))
printCall(x$call)
invisible(x)
}
1 change: 1 addition & 0 deletions pkg/caret/inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
\item A new argument to \code{lift} called \code{cuts} was added to allow more control over what thresholds are used to calculat the curve.
\item The \code{cuts} argument of \code{calibration} now accepts a vector of cut points.
\item Jason Schadewald noticed and fixed a bug in the man page for \code{dummyVars}
\item Call objects were remoed from the following models: \code{avNNet}, \code{bagFDA}, \code{icr}, \code{knn3}, \code{knnreg}, \code{pcaNNet}, and \code{plsda}.
}
}
Expand Down

0 comments on commit dfda220

Please sign in to comment.