Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed misc CRAN issues #1260

Merged
merged 2 commits into from
Mar 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions R-package/.Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
^build_package.R$
6 changes: 5 additions & 1 deletion R-package/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ Version: 2.1.0
Date: 2018-01-25
Author: Guolin Ke <[email protected]>
Maintainer: Guolin Ke <[email protected]>
Description: LightGBM is a gradient boosting framework that uses tree based learning algorithms.
Description: Tree based algorithms can be improved by introducing boosting frameworks. LightGBM is one such framework, and this package offers an R interface to work with it.
It is designed to be distributed and efficient with the following advantages:
1. Faster training speed and higher efficiency.
2. Lower memory usage.
3. Better accuracy.
4. Parallel learning supported.
5. Capable of handling large-scale data.
In recognition of these advantages, LightGBM has being widely-used in many winning solutions of machine learning competitions.

Comparison experiments on public datasets suggest that LightGBM can outperform existing boosting frameworks on both efficiency and accuracy, with significantly lower memory consumption. In addition, parallel experiments suggest that in certain circumstances, LightGBM can achieve a linear speed-up in training time by using multiple machines.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guolinke per your request, I've included additional details here. You will recognize most of this from the README you linked me too. I also added the line about "this is the R interface to the project" following the way XGBoost structured their DESCRIPTION: https://cran.r-project.org/web/packages/xgboost/index.html

I think that's a good clarification for people, to say that LightGBM is a framework and this is the interface to it implemented in a particular programming language.

License: MIT + file LICENSE
URL: https://github.com/Microsoft/LightGBM
BugReports: https://github.com/Microsoft/LightGBM/issues
Expand All @@ -30,6 +33,7 @@ Depends:
R (>= 3.0),
R6 (>= 2.0)
Imports:
graphics,
methods,
Matrix (>= 1.1-0),
data.table (>= 1.9.6),
Expand Down
3 changes: 3 additions & 0 deletions R-package/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export(slice)
import(methods)
importFrom(R6,R6Class)
importFrom(data.table,":=")
importFrom(data.table,set)
importFrom(graphics,barplot)
importFrom(graphics,par)
importFrom(magrittr,"%>%")
importFrom(magrittr,"%T>%")
useDynLib(lib_lightgbm)
3 changes: 2 additions & 1 deletion R-package/R/lgb.Booster.R
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@ Booster <- R6Class(
#' @param header only used for prediction for text file. True if text file has header
#' @param reshape whether to reshape the vector of predictions to a matrix form when there are several
#' prediction outputs per case.

#' @param ... Additional named arguments passed to the \code{predict()} method of
#' the \code{lgb.Booster} object passed to \code{object}.
#' @return
#' For regression or binary classification, it returns a vector of length \code{nrows(data)}.
#' For multiclass classification, either a \code{num_class * nrows(data)} vector or
Expand Down
6 changes: 2 additions & 4 deletions R-package/R/lgb.cv.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ CVBooster <- R6Class(
)
)

#' Main CV logic for LightGBM
#'
#' Main CV logic for LightGBM
#'
#' @title Main CV logic for LightGBM
#' @name lgb.cv
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this and lgb.train were getting grouped into a single documentation object with interwoven fields and R CMD CHECK complained about duplicated parameters. Using explicit @name elements avoids this

#' @param params List of parameters
#' @param data a \code{lgb.Dataset} object, used for CV
#' @param nrounds number of CV rounds
Expand Down
2 changes: 2 additions & 0 deletions R-package/R/lgb.model.dt.tree.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#' Parse a LightGBM model json dump into a \code{data.table} structure.
#'
#' @param model object of class \code{lgb.Booster}
#' @param num_iteration number of iterations you want to predict with. NULL or
#' <= 0 means use best iteration
#'
#' @return
#' A \code{data.table} with detailed information about model trees' nodes and leafs.
Expand Down
26 changes: 14 additions & 12 deletions R-package/R/lgb.plot.importance.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#' tree_imp <- lgb.importance(model, percentage = TRUE)
#' lgb.plot.importance(tree_imp, top_n = 10, measure = "Gain")
#' }
#'
#' @importFrom graphics barplot par
#' @export
lgb.plot.importance <- function(tree_imp,
top_n = 10,
Expand All @@ -54,22 +54,24 @@ lgb.plot.importance <- function(tree_imp,
}

# Refresh plot
op <- par(no.readonly = TRUE)
on.exit(par(op))
op <- graphics::par(no.readonly = TRUE)
on.exit(graphics::par(op))

# Do some magic plotting
par(mar = op$mar %>% magrittr::inset(., 2, left_margin))
graphics::par(mar = op$mar %>% magrittr::inset(., 2, left_margin))

# Do plot
tree_imp[.N:1,
barplot(height = get(measure),
names.arg = Feature,
horiz = TRUE,
border = NA,
main = "Feature Importance",
xlab = measure,
cex.names = cex,
las = 1)]
graphics::barplot(
height = get(measure),
names.arg = Feature,
horiz = TRUE,
border = NA,
main = "Feature Importance",
xlab = measure,
cex.names = cex,
las = 1
)]

# Return invisibly
invisible(tree_imp)
Expand Down
28 changes: 15 additions & 13 deletions R-package/R/lgb.plot.interpretation.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#' tree_interpretation <- lgb.interprete(model, test$data, 1:5)
#' lgb.plot.interpretation(tree_interpretation[[1]], top_n = 10)
#' }
#'
#' @importFrom graphics barplot par
#' @export
lgb.plot.interpretation <- function(tree_interpretation_dt,
top_n = 10,
Expand All @@ -48,11 +48,11 @@ lgb.plot.interpretation <- function(tree_interpretation_dt,
num_class <- ncol(tree_interpretation_dt) - 1

# Refresh plot
op <- par(no.readonly = TRUE)
on.exit(par(op))
op <- graphics::par(no.readonly = TRUE)
on.exit(graphics::par(op))

# Do some magic plotting
par(mar = op$mar %>% magrittr::inset(., 1:3, c(3, left_margin, 2)))
graphics::par(mar = op$mar %>% magrittr::inset(., 1:3, c(3, left_margin, 2)))

# Check for number of classes
if (num_class == 1) {
Expand All @@ -70,7 +70,7 @@ lgb.plot.interpretation <- function(tree_interpretation_dt,
ncol = cols, nrow = ceiling(num_class / cols))

# Shape output
par(mfcol = c(nrow(layout_mat), ncol(layout_mat)))
graphics::par(mfcol = c(nrow(layout_mat), ncol(layout_mat)))

# Loop throughout all classes
for (i in seq_len(num_class)) {
Expand Down Expand Up @@ -102,14 +102,16 @@ multiple.tree.plot.interpretation <- function(tree_interpretation,

# Do plot
tree_interpretation[.N:1,
barplot(height = Contribution,
names.arg = Feature,
horiz = TRUE,
col = ifelse(Contribution > 0, "firebrick", "steelblue"),
border = NA,
main = title,
cex.names = cex,
las = 1)]
graphics::barplot(
height = Contribution,
names.arg = Feature,
horiz = TRUE,
col = ifelse(Contribution > 0, "firebrick", "steelblue"),
border = NA,
main = title,
cex.names = cex,
las = 1
)]

# Return invisibly
invisible(NULL)
Expand Down
4 changes: 2 additions & 2 deletions R-package/R/lgb.train.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' Main training logic for LightGBM
#'
#' @title Main training logic for LightGBM
#' @name lgb.train
#' @param params List of parameters
#' @param data a \code{lgb.Dataset} object, used for training
#' @param nrounds number of training rounds
Expand Down
2 changes: 1 addition & 1 deletion R-package/R/lgb.unloader.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' Attempts to unload LightGBM packages so you can remove objects cleanly without having to restart R. This is useful for instance if an object becomes stuck for no apparent reason and you do not want to restart R to fix the lost object.
#'
#' @param restart Whether to reload \code{LightGBM} immediately after detaching from R. Defaults to \code{TRUE} which means automatically reload \code{LightGBM} once unloading is performed.
#' @param restore Whether to reload \code{LightGBM} immediately after detaching from R. Defaults to \code{TRUE} which means automatically reload \code{LightGBM} once unloading is performed.
#' @param wipe Whether to wipe all \code{lgb.Dataset} and \code{lgb.Booster} from the global environment. Defaults to \code{FALSE} which means to not remove them.
#' @param envir The environment to perform wiping on if \code{wipe == TRUE}. Defaults to \code{.GlobalEnv} which is the global environment.
#'
Expand Down
25 changes: 24 additions & 1 deletion R-package/R/lightgbm.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,28 @@ NULL
# Various imports
#' @import methods
#' @importFrom R6 R6Class
#' @useDynLib lightgbm
#' @useDynLib lib_lightgbm
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unable to build the package without making this change

NULL

# Suppress false positive warnings from R CMD CHECK about
# "unrecognized global variable"
globalVariables(c(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This suppresses the R CMD CHECK warning about "unrecognized global variables"

"."
, ".N"
, ".SD"
, "Contribution"
, "Cover"
, "Feature"
, "Frequency"
, "Gain"
, "internal_count"
, "internal_value"
, "leaf_index"
, "leaf_parent"
, "leaf_value"
, "node_parent"
, "split_feature"
, "split_gain"
, "split_index"
, "tree_index"
))
4 changes: 4 additions & 0 deletions R-package/man/lgb.model.dt.tree.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion R-package/man/lgb.plot.importance.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion R-package/man/lgb.plot.interpretation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 51 additions & 51 deletions R-package/man/lgb.prepare.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading