fix namespace and desc
This commit is contained in:
parent
141f9ebf4b
commit
198c5bb55e
@ -3,3 +3,4 @@
|
|||||||
\.dll$
|
\.dll$
|
||||||
^.*\.Rproj$
|
^.*\.Rproj$
|
||||||
^\.Rproj\.user$
|
^\.Rproj\.user$
|
||||||
|
README.md
|
||||||
|
|||||||
@ -5,7 +5,7 @@ Version: 0.4-0
|
|||||||
Date: 2015-05-11
|
Date: 2015-05-11
|
||||||
Author: Tianqi Chen <tianqi.tchen@gmail.com>, Tong He <hetong007@gmail.com>, Michael Benesty <michael@benesty.fr>
|
Author: Tianqi Chen <tianqi.tchen@gmail.com>, Tong He <hetong007@gmail.com>, Michael Benesty <michael@benesty.fr>
|
||||||
Maintainer: Tong He <hetong007@gmail.com>
|
Maintainer: Tong He <hetong007@gmail.com>
|
||||||
Description: Xgboost is short for eXtreme Gradient Boosting, which is an
|
Description: eXtreme Gradient Boosting, which is an
|
||||||
efficient and scalable implementation of gradient boosting framework.
|
efficient and scalable implementation of gradient boosting framework.
|
||||||
This package is an R wrapper of xgboost. The package includes efficient
|
This package is an R wrapper of xgboost. The package includes efficient
|
||||||
linear model solver and tree learning algorithms. The package can automatically
|
linear model solver and tree learning algorithms. The package can automatically
|
||||||
|
|||||||
@ -288,7 +288,7 @@ xgb.cv.aggcv <- function(res, showsd = TRUE) {
|
|||||||
}
|
}
|
||||||
ret <- paste(ret, sprintf("%f", mean(stats)), sep="")
|
ret <- paste(ret, sprintf("%f", mean(stats)), sep="")
|
||||||
if (showsd) {
|
if (showsd) {
|
||||||
ret <- paste(ret, sprintf("+%f", sd(stats)), sep="")
|
ret <- paste(ret, sprintf("+%f", stats::sd(stats)), sep="")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (ret)
|
return (ret)
|
||||||
@ -313,7 +313,7 @@ xgb.createFolds <- function(y, k = 10)
|
|||||||
if(cuts < 2) cuts <- 2
|
if(cuts < 2) cuts <- 2
|
||||||
if(cuts > 5) cuts <- 5
|
if(cuts > 5) cuts <- 5
|
||||||
y <- cut(y,
|
y <- cut(y,
|
||||||
unique(quantile(y, probs = seq(0, 1, length = cuts))),
|
unique(stats::quantile(y, probs = seq(0, 1, length = cuts))),
|
||||||
include.lowest = TRUE)
|
include.lowest = TRUE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -240,7 +240,7 @@ xgb.cv <- function(params=list(), data, nrounds, nfold, label = NULL, missing =
|
|||||||
else colnames <- colnamesMean
|
else colnames <- colnamesMean
|
||||||
|
|
||||||
type <- rep(x = "numeric", times = length(colnames))
|
type <- rep(x = "numeric", times = length(colnames))
|
||||||
dt <- read.table(text = "", colClasses = type, col.names = colnames) %>% as.data.table
|
dt <- utils::read.table(text = "", colClasses = type, col.names = colnames) %>% as.data.table
|
||||||
split <- str_split(string = history, pattern = "\t")
|
split <- str_split(string = history, pattern = "\t")
|
||||||
|
|
||||||
for(line in split) dt <- line[2:length(line)] %>% str_extract_all(pattern = "\\d*\\.+\\d*") %>% unlist %>% as.numeric %>% as.list %>% {rbindlist(list(dt, .), use.names = F, fill = F)}
|
for(line in split) dt <- line[2:length(line)] %>% str_extract_all(pattern = "\\d*\\.+\\d*") %>% unlist %>% as.numeric %>% as.list %>% {rbindlist(list(dt, .), use.names = F, fill = F)}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ xgb.plot.importance <- function(importance_matrix = NULL, numberOfClusters = c(1
|
|||||||
if (!"data.table" %in% class(importance_matrix)) {
|
if (!"data.table" %in% class(importance_matrix)) {
|
||||||
stop("importance_matrix: Should be a data.table.")
|
stop("importance_matrix: Should be a data.table.")
|
||||||
}
|
}
|
||||||
if (!require(ggplot2, quietly = TRUE)) {
|
if (!requireNamespace(ggplot2, quietly = TRUE)) {
|
||||||
stop("ggplot2 package is required for plotting the importance", call. = FALSE)
|
stop("ggplot2 package is required for plotting the importance", call. = FALSE)
|
||||||
}
|
}
|
||||||
if (!requireNamespace("Ckmeans.1d.dp", quietly = TRUE)) {
|
if (!requireNamespace("Ckmeans.1d.dp", quietly = TRUE)) {
|
||||||
@ -46,7 +46,7 @@ xgb.plot.importance <- function(importance_matrix = NULL, numberOfClusters = c(1
|
|||||||
clusters <- suppressWarnings(Ckmeans.1d.dp::Ckmeans.1d.dp(importance_matrix[,Gain], numberOfClusters))
|
clusters <- suppressWarnings(Ckmeans.1d.dp::Ckmeans.1d.dp(importance_matrix[,Gain], numberOfClusters))
|
||||||
importance_matrix[,"Cluster":=clusters$cluster %>% as.character]
|
importance_matrix[,"Cluster":=clusters$cluster %>% as.character]
|
||||||
|
|
||||||
plot <- ggplot(importance_matrix, aes(x=reorder(Feature, Gain), y = Gain, width= 0.05), environment = environment())+ geom_bar(aes(fill=Cluster), stat="identity", position="identity") + coord_flip() + xlab("Features") + ylab("Gain") + ggtitle("Feature importance") + theme(plot.title = element_text(lineheight=.9, face="bold"), panel.grid.major.y = element_blank() )
|
plot <- ggplot(importance_matrix, aes(x=stats::reorder(Feature, Gain), y = Gain, width= 0.05), environment = environment())+ geom_bar(aes(fill=Cluster), stat="identity", position="identity") + coord_flip() + xlab("Features") + ylab("Gain") + ggtitle("Feature importance") + theme(plot.title = element_text(lineheight=.9, face="bold"), panel.grid.major.y = element_blank() )
|
||||||
|
|
||||||
return(plot)
|
return(plot)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user