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

[R-package] fix R examples and lgb.plot.interpretation() #2999

Closed
wants to merge 2 commits into from
Closed
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
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,14 @@ lightgbm_r/*
lightgbm*.tar.gz
lightgbm.Rcheck/

# Files created by R examples and tests
**/lgb-Dataset.data
**/lgb-model.rds
**/lgb.Dataset.data
**/model.rds
**/model.txt
**/lgb-model.txt

# Files from interactive R sessions
.Rproj.user
**/.Rhistory
Expand Down
2 changes: 1 addition & 1 deletion R-package/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ Imports:
utils
SystemRequirements:
C++11
RoxygenNote: 7.0.2
RoxygenNote: 7.1.0
2 changes: 1 addition & 1 deletion R-package/R/lgb.Booster.R
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ lgb.load <- function(filename = NULL, model_str = NULL) {
#' , learning_rate = 1.0
#' , early_stopping_rounds = 5L
#' )
#' lgb.save(model, "model.txt")
#' lgb.save(model, "lgb-model.txt")
#' }
#' @export
lgb.save <- function(booster, filename, num_iteration = NULL) {
Expand Down
4 changes: 2 additions & 2 deletions R-package/R/lgb.Dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -1073,8 +1073,8 @@ setinfo.lgb.Dataset <- function(dataset, name, info, ...) {
#' data(agaricus.train, package = "lightgbm")
#' train <- agaricus.train
#' dtrain <- lgb.Dataset(train$data, label = train$label)
#' lgb.Dataset.save(dtrain, "lgb.Dataset.data")
#' dtrain <- lgb.Dataset("lgb.Dataset.data")
#' lgb.Dataset.save(dtrain, "lgb-Dataset.data")
#' dtrain <- lgb.Dataset("lgb-Dataset.data")
#' lgb.Dataset.set.categorical(dtrain, 1L:2L)
#'
#' @rdname lgb.Dataset.set.categorical
Expand Down
4 changes: 2 additions & 2 deletions R-package/R/lgb.plot.interpretation.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#' )
#' lgb.plot.interpretation(
#' tree_interpretation_dt = tree_interpretation[[1L]]
#' , top_n = 5L
#' , top_n = 3L
#' )
#' }
#' @importFrom data.table setnames
Expand Down Expand Up @@ -141,7 +141,7 @@ multiple.tree.plot.interpretation <- function(tree_interpretation,
}

# create plot
tree_interpretation[Contribution > 0.0, bar_color := "firebrick"]
tree_interpretation[abs(Contribution) > 0.0, bar_color := "firebrick"]
tree_interpretation[Contribution == 0.0, bar_color := "steelblue"]
tree_interpretation[.N:1L,
graphics::barplot(
Expand Down
10 changes: 7 additions & 3 deletions R-package/R/lgb.prepare_rules.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@
#' data(iris) # Erase iris dataset
#'
#' # We remapped values differently
#' personal_rules <- list(Species = c("setosa" = 3L,
#' "versicolor" = 2L,
#' "virginica" = 1L))
#' personal_rules <- list(
#' Species = c(
#' "setosa" = 3L
#' , "versicolor" = 2L
#' , "virginica" = 1L
#' )
#' )
#' newest_iris <- lgb.prepare_rules(data = iris, rules = personal_rules)
#' str(newest_iris$data) # SUCCESS!
#'
Expand Down
2 changes: 1 addition & 1 deletion R-package/R/saveRDS.lgb.Booster.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#' , learning_rate = 1.0
#' , early_stopping_rounds = 5L
#' )
#' saveRDS.lgb.Booster(model, "model.rds")
#' saveRDS.lgb.Booster(model, "lgb-model.rds")
#' }
#' @export
saveRDS.lgb.Booster <- function(object,
Expand Down
6 changes: 4 additions & 2 deletions R-package/man/agaricus.test.Rd

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

6 changes: 4 additions & 2 deletions R-package/man/agaricus.train.Rd

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

4 changes: 3 additions & 1 deletion R-package/man/bank.Rd

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

4 changes: 2 additions & 2 deletions R-package/man/lgb.Dataset.set.categorical.Rd

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

2 changes: 1 addition & 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.

10 changes: 7 additions & 3 deletions R-package/man/lgb.prepare_rules.Rd

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

2 changes: 1 addition & 1 deletion R-package/man/lgb.save.Rd

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

2 changes: 1 addition & 1 deletion R-package/man/saveRDS.lgb.Booster.Rd

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

2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def generate_r_docs(app):
/home/docs/.conda/bin/conda create -q -y -n r_env \
r-base=3.5.1=h1e0a451_2 \
r-devtools=1.13.6=r351h6115d3f_0 \
r-data.table=1.11.4=r351h96ca727_0 \
r-data.table=1.12.2=r36h96ca727_0 \
r-jsonlite=1.5=r351h96ca727_0 \
r-matrix=1.2_14=r351h96ca727_0 \
r-testthat=2.0.0=r351h29659fb_0 \
Expand Down