-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42e9dfe
commit 1ff4e34
Showing
13 changed files
with
232 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(...) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(...) | ||
) | ||
} | ||
|
Oops, something went wrong.