Skip to content

Commit

Permalink
version 1.1-7
Browse files Browse the repository at this point in the history
  • Loading branch information
topepo authored and cran-robot committed May 22, 2018
1 parent 42e9dfe commit 1ff4e34
Show file tree
Hide file tree
Showing 13 changed files with 232 additions and 204 deletions.
17 changes: 9 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
Package: AppliedPredictiveModeling
Type: Package
Title: Functions and Data Sets for 'Applied Predictive Modeling'
Version: 1.1-6
Date: 2014-07-24
Version: 1.1-7
Date: 2018-05-22
Author: Max Kuhn, Kjell Johnson
Maintainer: Max Kuhn <[email protected]>
Description: A few functions and several data set for the Springer book 'Applied Predictive Modeling'
Description: A few functions and several data set for the Springer book 'Applied Predictive Modeling'.
URL: http://appliedpredictivemodeling.com/
Depends: R (>= 2.10)
Imports: CORElearn, MASS, plyr, reshape2
Suggests: caret (>= 6.0-22), lattice, ellipse
License: GPL
Packaged: 2014-07-25 13:37:54 UTC; kuhna03
Imports: CORElearn, MASS, plyr, reshape2, lattice, ellipse
Suggests: caret (>= 6.0-22)
License: GPL-2
RoxygenNote: 6.0.1
NeedsCompilation: no
Packaged: 2018-05-22 19:03:00 UTC; max
Repository: CRAN
Date/Publication: 2014-07-25 18:42:22
Date/Publication: 2018-05-22 19:14:21 UTC
23 changes: 12 additions & 11 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
b956c4b3e5aad17e35ac120a5d5f59d3 *DESCRIPTION
03e5df17ec09e62322761dbf70cd3a8a *NAMESPACE
e4e564d2188913c297d854a86868bd37 *R/bookTheme.R
538821ec8c21e26d4b936611aa157bc4 *R/easyBoundaryFunc.R
f4e5463cfcc4da4261f8014b1426c10c *R/getPackages.R
35a9e06d580a6ed8b8d98c9f3c0a61eb *R/panels.R
57c3568c0838c1acba62489985f0dea9 *R/permuteRelief.R
5996be154af6ef121fab077294b2e5e0 *R/quadBoundaryFunc.R
d35f915bd2268cbb07c258bd8fce5c50 *R/scriptLocation.R
98d928db47d8347a4f886f0c8e4adde1 *R/transparentTheme.R
d9a47751fc337024c1a1c41e1da27221 *DESCRIPTION
f78a4ad513d2c6c72c50fb7c8c3c4fa6 *NAMESPACE
4ba4117b0411d3dffc0016338e086487 *R/bookTheme.R
ba7591c480e18250a36afca890626919 *R/easyBoundaryFunc.R
4bcab4abad6714d7dded5c1bc3924c0c *R/getPackages.R
4eeffcbe6c341af031b5ca224ddc01e3 *R/panels.R
2cd8668d7140eff6b9bbb10e281ff643 *R/permuteRelief.R
f8804618082623af1ab53f6eda5d6c6e *R/quadBoundaryFunc.R
ea3ad783d73b8ecd91c3df840f944bfe *R/scriptLocation.R
b7ba633adffdafee73c75abba35be85c *R/transparentTheme.R
cb9165768774234eeda3f6e724fa4bae *README.md
8a34126ad3a2f9d077653b26d950dddb *data/AlzheimerDisease.RData
fe3de40e923db3e0133b269f1610afa2 *data/ChemicalManufacturingProcess.RData
ef3addd28ad9449688f0c33ba9bfc2d0 *data/FuelEconomy.RData
Expand All @@ -21,7 +22,7 @@ e1590269851cf810fdffa832b6cf6d65 *data/schedulingData.RData
669172e9b524f9194a23fbc84a2816f8 *data/segmentationOriginal.RData
06780bd86a4db76cb2a8eb12ef107df7 *data/solubility.RData
5e5422a8c05125f3ab1822f6c525296a *data/twoClassData.RData
47ca37b7084f35df9345c9c5b6a3d461 *inst/NEWS.Rd
7973bb1a98c7ee6c2e08604fbd923d59 *inst/NEWS.Rd
55afb317aa767a6e82c6c52ee985563f *inst/chapters/02_A_Short_Tour.R
5a487c219abde639b85d7275c6a4bf31 *inst/chapters/02_A_Short_Tour.Rout
ec4768cf8bf24124e998a1ce680dceb6 *inst/chapters/03_Data_Pre_Processing.R
Expand Down
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
exportPattern("^[[:alpha:]]+")

import(CORElearn, MASS, plyr, reshape2)
importFrom("grDevices", "rgb")
importFrom("stats", "runif", "sd")
importFrom("utils", "install.packages")
importFrom("lattice", "trellis.par.set", "trellis.par.get", "panel.xyplot")
importFrom("ellipse", "ellipse")
145 changes: 75 additions & 70 deletions R/bookTheme.R
Original file line number Diff line number Diff line change
@@ -1,70 +1,75 @@
bookTheme <- function(set = TRUE)
{
library(lattice)
theme <- list(plot.polygon = list(alpha = 1, col = "aliceblue", border = "black", lty = 1, lwd = 1),
background = list(col = "transparent"),
bar.fill = list(col = "#cce6ff"),
box.rectangle = list(col = "black"),
box.umbrella = list(col = "black"),
dot.line = list(col = "#e8e8e8"),
dot.symbol = list(col = "black"),
plot.line = list(col = "black", lwd = 1, lty = 1),
plot.symbol = list(col = "black", pch = 16),
regions = list(col =
c("#FEF8FA", "#FDF6F9", "#FBF5F9", "#FAF3F8",
"#F8F2F7", "#F7F0F7", "#F5EEF6", "#F4EDF5",
"#F2EBF5", "#F1EAF4", "#EFE8F3", "#EDE7F2",
"#ECE5F1", "#EAE4F1", "#E8E2F0", "#E6E1EF",
"#E4DFEE", "#E2DEED", "#E0DCEC", "#DEDAEB",
"#DCD9EA", "#D9D7E9", "#D7D6E8", "#D4D4E7",
"#D1D2E6", "#CED1E5", "#CCCFE4", "#C8CEE3",
"#C5CCE2", "#C2CAE1", "#BFC9E0", "#BBC7DF",
"#B8C5DF", "#B4C4DE", "#B1C2DD", "#ADC0DC",
"#A9BFDB", "#A6BDDA", "#A2BBD9", "#9EB9D9",
"#9BB8D8", "#97B6D7", "#93B4D6", "#8FB2D5",
"#8BB0D4", "#87AFD3", "#83ADD2", "#7FABD1",
"#7AA9D0", "#76A7CF", "#71A5CE", "#6CA3CC",
"#68A1CB", "#63A0CA", "#5D9EC9", "#589CC8",
"#539AC6", "#4E98C5", "#4996C4", "#4493C3",
"#3F91C1", "#3A8FC0", "#358DBF", "#308BBE",
"#2C89BD", "#2887BC", "#2385BB", "#1F83BA",
"#1C80B9", "#187EB7", "#157CB6", "#127AB5",
"#0F78B3", "#0D76B2", "#0A73B0", "#0971AE",
"#076FAC", "#066DAA", "#056AA7", "#0568A5")
),
strip.shingle = list(col = c(
"#ff7f00", "#00ff00", "#00ffff",
"#ff00ff", "#ff0000", "#ffff00", "#0080ff")),
strip.background = list(col = c(
"#ffe5cc", "#ccffcc", "#ccffff",
"#ffccff", "#ffcccc", "#ffffcc", "#cce6ff")),
reference.line = list(col = "#e8e8e8"),
superpose.line = list(
col = c(
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black"),
lty = rep(1:6, each = 6)),
superpose.symbol = list(
pch = c(
1, 4, 6, 0, 5, 17,
4, 6, 0, 5, 17, 1,
6, 0, 5, 17, 1, 4,
0, 5, 17, 1, 4, 6,
5, 17, 1, 4, 6, 0 ,
17, 1, 4, 6, 0, 5),
cex = rep(0.7, 6 * 6),
col = c(
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black")))

if(set) trellis.par.set(theme)
invisible(theme)
}
bookTheme <- function(set = TRUE){
theme <- list(
plot.polygon = list(alpha = 1, col = "aliceblue", border = "black", lty = 1, lwd = 1),
background = list(col = "transparent"),
bar.fill = list(col = "#cce6ff"),
box.rectangle = list(col = "black"),
box.umbrella = list(col = "black"),
dot.line = list(col = "#e8e8e8"),
dot.symbol = list(col = "black"),
plot.line = list(col = "black", lwd = 1, lty = 1),
plot.symbol = list(col = "black", pch = 16),
regions = list(col =
c("#FEF8FA", "#FDF6F9", "#FBF5F9", "#FAF3F8",
"#F8F2F7", "#F7F0F7", "#F5EEF6", "#F4EDF5",
"#F2EBF5", "#F1EAF4", "#EFE8F3", "#EDE7F2",
"#ECE5F1", "#EAE4F1", "#E8E2F0", "#E6E1EF",
"#E4DFEE", "#E2DEED", "#E0DCEC", "#DEDAEB",
"#DCD9EA", "#D9D7E9", "#D7D6E8", "#D4D4E7",
"#D1D2E6", "#CED1E5", "#CCCFE4", "#C8CEE3",
"#C5CCE2", "#C2CAE1", "#BFC9E0", "#BBC7DF",
"#B8C5DF", "#B4C4DE", "#B1C2DD", "#ADC0DC",
"#A9BFDB", "#A6BDDA", "#A2BBD9", "#9EB9D9",
"#9BB8D8", "#97B6D7", "#93B4D6", "#8FB2D5",
"#8BB0D4", "#87AFD3", "#83ADD2", "#7FABD1",
"#7AA9D0", "#76A7CF", "#71A5CE", "#6CA3CC",
"#68A1CB", "#63A0CA", "#5D9EC9", "#589CC8",
"#539AC6", "#4E98C5", "#4996C4", "#4493C3",
"#3F91C1", "#3A8FC0", "#358DBF", "#308BBE",
"#2C89BD", "#2887BC", "#2385BB", "#1F83BA",
"#1C80B9", "#187EB7", "#157CB6", "#127AB5",
"#0F78B3", "#0D76B2", "#0A73B0", "#0971AE",
"#076FAC", "#066DAA", "#056AA7", "#0568A5")
),
strip.shingle = list(col = c(
"#ff7f00", "#00ff00", "#00ffff",
"#ff00ff", "#ff0000", "#ffff00", "#0080ff")
),
strip.background = list(col = c(
"#ffe5cc", "#ccffcc", "#ccffff",
"#ffccff", "#ffcccc", "#ffffcc", "#cce6ff")
),
reference.line = list(col = "#e8e8e8"),
superpose.line = list(
col = c(
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black"
),
lty = rep(1:6, each = 6)),
superpose.symbol = list(
pch = c(
1, 4, 6, 0, 5, 17,
4, 6, 0, 5, 17, 1,
6, 0, 5, 17, 1, 4,
0, 5, 17, 1, 4, 6,
5, 17, 1, 4, 6, 0 ,
17, 1, 4, 6, 0, 5),
cex = rep(0.7, 6 * 6),
col = c(
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black",
"#053061", "#B2182B", "#F46D43", "#5E4FA2", "#66C2A5", "black"
)
)
)

if(set) trellis.par.set(theme)
invisible(theme)
}
31 changes: 18 additions & 13 deletions R/easyBoundaryFunc.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@

easyBoundaryFunc <- function(n, intercept = 0, interaction = 2)
{
sigma <- matrix(c(2,1.3,1.3,2),2,2)

tmpData <- data.frame(mvrnorm(n=n, c(0,0), sigma))
xSeq <- seq(-4, 4, length=40)
plotGrid <- expand.grid(x = xSeq, y = xSeq)
zFoo <- function(x, y) intercept -4 * x + 4* y + interaction*x*y
z2p <- function(x) 1/(1+exp(-x))

tmpData$prob <- z2p(zFoo(tmpData$X1, tmpData$X2))
tmpData$class <- factor(ifelse(runif(length(tmpData$prob)) <= tmpData$prob, "Class1", "Class2"))
tmpData

easyBoundaryFunc <- function(n,
intercept = 0,
interaction = 2) {
sigma <- matrix(c(2, 1.3, 1.3, 2), 2, 2)

tmpData <- data.frame(mvrnorm(n = n, c(0, 0), sigma))
xSeq <- seq(-4, 4, length = 40)
plotGrid <- expand.grid(x = xSeq, y = xSeq)
zFoo <- function(x, y)
intercept - 4 * x + 4 * y + interaction * x * y
z2p <- function(x)
1 / (1 + exp(-x))

tmpData$prob <- z2p(zFoo(tmpData$X1, tmpData$X2))
tmpData$class <-
factor(ifelse(runif(length(tmpData$prob)) <= tmpData$prob, "Class1", "Class2"))
tmpData
}
18 changes: 9 additions & 9 deletions R/getPackages.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@


getPackages <- function(chapter, ...)
{
if(is.numeric(chapter)) chapter <- paste(chapter)
getPackages <- function(chapter, ...) {
if(is.numeric(chapter))
chapter <- paste(chapter)
pkg <- list()
pkg[["2"]] <- c("earth", "caret", "lattice")
pkg[["3"]] <- c("e1071", "caret", "corrplot")
Expand Down Expand Up @@ -30,16 +30,16 @@ getPackages <- function(chapter, ...)
pkg[["18"]] <- c("caret", "CORElearn", "corrplot", "pROC", "minerva")
pkg[["19"]] <- c("caret", "MASS", "corrplot", "RColorBrewer", "randomForest",
"kernlab", "klaR")
plist <- paste(paste("'", names(pkg), "'", sep = ""), collapse = ", ")
if(!any(chapter %in% names(pkg))) stop(paste("'chapter' must be: ",
paste(plist, collapse = ", ")),
sep = "")

plist <-
paste(paste("'", names(pkg), "'", sep = ""), collapse = ", ")
if (!any(chapter %in% names(pkg)))
stop(paste("'chapter' must be: ",
paste(plist, collapse = ", ")))

pkg <- unlist(pkg[chapter])
pkg <- pkg[!is.na(pkg)]
pkg <- pkg[pkg != ""]
pkg <- pkg[order(tolower(pkg))]

install.packages(pkg, ...)
}
66 changes: 37 additions & 29 deletions R/panels.R
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
upperp <- function(...)
{
library(ellipse)
args <- list(...)
circ1 <- ellipse(diag(rep(1, 2)), t = .1)
panel.xyplot(circ1[,1], circ1[,2],
type = "l",
lty = trellis.par.get("reference.line")$lty,
col = trellis.par.get("reference.line")$col,
lwd = trellis.par.get("reference.line")$lwd)
circ2 <- ellipse(diag(rep(1, 2)), t = .2)
panel.xyplot(circ2[,1], circ2[,2],
type = "l",
lty = trellis.par.get("reference.line")$lty,
col = trellis.par.get("reference.line")$col,
lwd = trellis.par.get("reference.line")$lwd)
circ3 <- ellipse(diag(rep(1, 2)), t = .3)
panel.xyplot(circ3[,1], circ3[,2],
type = "l",
lty = trellis.par.get("reference.line")$lty,
col = trellis.par.get("reference.line")$col,
lwd = trellis.par.get("reference.line")$lwd)
panel.xyplot(args$x, args$y, groups = args$groups, subscripts = args$subscripts)
}

lowerp <- function(...)
{

}
upperp <- function(...) {
args <- list(...)
circ1 <- ellipse(diag(rep(1, 2)), t = .1)
panel.xyplot(
circ1[, 1],
circ1[, 2],
type = "l",
lty = trellis.par.get("reference.line")$lty,
col = trellis.par.get("reference.line")$col,
lwd = trellis.par.get("reference.line")$lwd
)
circ2 <- ellipse(diag(rep(1, 2)), t = .2)
panel.xyplot(
circ2[, 1],
circ2[, 2],
type = "l",
lty = trellis.par.get("reference.line")$lty,
col = trellis.par.get("reference.line")$col,
lwd = trellis.par.get("reference.line")$lwd
)
circ3 <- ellipse(diag(rep(1, 2)), t = .3)
panel.xyplot(
circ3[, 1],
circ3[, 2],
type = "l",
lty = trellis.par.get("reference.line")$lty,
col = trellis.par.get("reference.line")$col,
lwd = trellis.par.get("reference.line")$lwd
)
panel.xyplot(args$x,
args$y,
groups = args$groups,
subscripts = args$subscripts)
}

lowerp <- function(...) {

}
23 changes: 11 additions & 12 deletions R/permuteRelief.R
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
permuteRelief <-
function(x, y, nperm = 100, ...)
{
function(x, y, nperm = 100, ...) {
dat <- x
dat$y <- y

obs <- attrEval(y ~ ., data = dat, ...)
permuted <- matrix(NA, ncol = length(obs), nrow = nperm)
colnames(permuted) <- names(obs)
for(i in 1:nperm)
{
dat$y <- sample(y)
permuted[i,] <- attrEval(y ~ ., data = dat, ...)
}
for (i in 1:nperm) {
dat$y <- sample(y)
permuted[i,] <- attrEval(y ~ ., data = dat, ...)
}
means <- colMeans(permuted)
sds <- apply(permuted, 2, sd)
permuted <- melt(permuted)
names(permuted)[2] <- "Predictor"
permuted$X1 <- NULL
list(standardized = (obs - means)/sds,
permutations = permuted,
observed = obs,
options = list(...))
list(
standardized = (obs - means) / sds,
permutations = permuted,
observed = obs,
options = list(...)
)
}

Loading

0 comments on commit 1ff4e34

Please sign in to comment.