-
Notifications
You must be signed in to change notification settings - Fork 2
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
5b81315
commit 0ccbfbb
Showing
11 changed files
with
250 additions
and
90 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
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,19 +1,32 @@ | ||
plot.csboost <- function (x, ...) { | ||
plot.csboost <- function (x, legend_position = NULL, ...) { | ||
# check inputs | ||
if (missing(x)) { | ||
stop("argument 'x' is missing, with no default") | ||
} | ||
if (class(x) != "csboost") { | ||
stop("argument 'x' must be of class 'csboost'") | ||
} | ||
if (!is.null(legend_position)) { | ||
if (!legend_position %in% c("bottomright", "bottom", "bottomleft", "left", "topleft", | ||
"top", "topright", "right", "center")) { | ||
stop(paste("'legend_position' should be one of \"bottomright\", \"bottom\", \"bottomleft\",", | ||
"\"left\", \"topleft\", \"top\", \"topright\", \"right\", \"center\"")) | ||
} | ||
} | ||
|
||
# plot expected savings versus iteration | ||
# plot average expected cost versus iteration | ||
evallog <- x$xgbmodel$evaluation_log | ||
plot(evallog$iter, unlist(evallog[, 2]), type = "l", lwd = 2, | ||
ylim = range(evallog[, 2:NCOL(evallog)]), ylab = "expected savings", xlab = "iteration") | ||
ylimit <- range(evallog[, 2:NCOL(evallog)]) | ||
|
||
plot(evallog$iter, unlist(evallog[, 2]), type = "l", ylim = ylimit, | ||
ylab = "average expected cost", xlab = "iteration", ...) | ||
|
||
if (NCOL(evallog) == 3) { | ||
lines(evallog$iter, unlist(evallog[, 3]), lty = 2, lwd = 2) | ||
legend("right", legend = c("train", "test"), lty = c(1, 2), lwd = 2) | ||
lines(evallog$iter, unlist(evallog[, 3]), lty = 2, ...) | ||
if (is.null(legend_position)) { | ||
legend_position <- "top" | ||
} | ||
abline(v = x$xgbmodel$best_iteration, lty = 4, ...) | ||
legend(legend_position, legend = c("train", "test"), lty = c(1, 2), lwd = 2) | ||
} | ||
abline(v = x$xgbmodel$best_iteration, lty = 3, lwd = 2) | ||
} |
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
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
\name{creditcard} | ||
\docType{data} | ||
\alias{creditcard} | ||
\title{Creditcard Transaction Data} | ||
\description{ | ||
Transactions made by credit cards in September 2013 by European cardholders. This data set presents a small subset of transactions that occurred in two days, where we have 465 frauds out of 1409 transactions. It contains only numerical input variables which are the result of a PCA transformation. Due to confidentiality issues, the original features and more background information about the data cannot be provided. Features V1, V2, ..., V28 are the principal components obtained with PCA. The only feature which has not been transformed with PCA is ‘Amount’ which is the transaction amount. Feature ‘Class’ is the response variable which takes value 1 in case of fraud and 0 otherwise. | ||
} | ||
\usage{data(creditcard)} | ||
\format{A data frame containing 1409 observations and 30 variables.} | ||
\source{kaggle.com, made available by Andrea Dal Pozzolo et al., Calibrating Probability with Undersampling for Unbalanced Classification. In Symposium on Computational Intelligence and Data Mining (CIDM), IEEE, 2015.} | ||
\keyword{datasets} | ||
\examples{ | ||
data(creditcard) | ||
str(creditcard) | ||
head(creditcard) | ||
summary(creditcard) | ||
} |
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
Oops, something went wrong.