Skip to content

Commit

Permalink
restore \donttest
Browse files Browse the repository at this point in the history
  • Loading branch information
krzyzinskim committed Sep 29, 2023
1 parent c54b77f commit 2b8b65c
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions R/plot_contribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#'
#'
#' @examples
#' \donttest{
#' library(xgboost)
#' data <- fifa20$data[colnames(fifa20$data) != 'work_rate']
#' target <- fifa20$target
Expand All @@ -36,6 +37,7 @@
#' x <- head(data, 1)
#' shap <- treeshap(unified_model, x)
#' plot_contribution(shap, 1, min_max = c(0, 120000000))
#' }
plot_contribution <- function(treeshap,
obs = 1,
max_vars = 5,
Expand Down
2 changes: 2 additions & 0 deletions R/plot_feature_dependence.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#'
#'
#' @examples
#' \donttest{
#' library(xgboost)
#' data <- fifa20$data[colnames(fifa20$data) != 'work_rate']
#' target <- fifa20$target
Expand All @@ -30,6 +31,7 @@
#' x <- head(data, 100)
#' shaps <- treeshap(unified_model, x)
#' plot_feature_dependence(shaps, variable = "overall")
#' }
plot_feature_dependence <- function(treeshap, variable,
title = "Feature Dependence", subtitle = NULL) {

Expand Down
2 changes: 2 additions & 0 deletions R/plot_interaction.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
#'
#'
#' @examples
#' \donttest{
#' data <- fifa20$data[colnames(fifa20$data) != 'work_rate']
#' target <- fifa20$target
#' param2 <- list(objective = "reg:squarederror", max_depth = 5)
#' xgb_model2 <- xgboost::xgboost(as.matrix(data), params = param2, label = target, nrounds = 10)
#' unified_model2 <- xgboost.unify(xgb_model2, data)
#' inters <- treeshap(unified_model2, as.matrix(data[1:50, ]), interactions = TRUE)
#' plot_interaction(inters, "dribbling", "defending")
#' }
plot_interaction <- function(treeshap, var1, var2,
title = "SHAP Interaction Value Plot",
subtitle = "") {
Expand Down
2 changes: 2 additions & 0 deletions R/predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#' @export
#'
#' @examples
#' \donttest{
#' library(gbm)
#' data <- fifa20$data[colnames(fifa20$data) != 'work_rate']
#' data['value_eur'] <- fifa20$target
Expand All @@ -23,6 +24,7 @@
#' n.cores = 1)
#' unified <- gbm.unify(gbm_model, data)
#' predict(unified, data[2001:2005, ])
#' }
predict.model_unified <- function(object, x, ...) {
unified_model <- object
model <- unified_model$model
Expand Down
2 changes: 2 additions & 0 deletions R/set_reference_dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#' \code{\link{randomForest.unify}} for \code{\link[randomForest:randomForest]{randomForest models}}
#'
#' @examples
#' \donttest{
#' library(gbm)
#' data <- fifa20$data[colnames(fifa20$data) != 'work_rate']
#' data['value_eur'] <- fifa20$target
Expand All @@ -38,6 +39,7 @@
#' n.cores = 1)
#' unified <- gbm.unify(gbm_model, data)
#' set_reference_dataset(unified, data[200:700, ])
#' }
set_reference_dataset <- function(unified_model, x) {
model <- unified_model$model
data <- x
Expand Down
2 changes: 2 additions & 0 deletions R/unify_gbm.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#' \code{\link{randomForest.unify}} for \code{\link[randomForest:randomForest]{randomForest models}}
#'
#' @examples
#' \donttest{
#' library(gbm)
#' data <- fifa20$data[colnames(fifa20$data) != 'work_rate']
#' data['value_eur'] <- fifa20$target
Expand All @@ -34,6 +35,7 @@
#' unified_model <- gbm.unify(gbm_model, data)
#' shaps <- treeshap(unified_model, data[1:2,])
#' plot_contribution(shaps, obs = 1)
#' }
gbm.unify <- function(gbm_model, data) {
if(!inherits(gbm_model,'gbm')) {
stop('Object gbm_model was not of class "gbm"')
Expand Down
2 changes: 2 additions & 0 deletions R/unify_lightgbm.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#' \code{\link{randomForest.unify}} for \code{\link[randomForest:randomForest]{randomForest models}}
#'
#' @examples
#' \donttest{
#' library(lightgbm)
#' param_lgbm <- list(objective = "regression", max_depth = 2,
#' force_row_wise = TRUE, num_iterations = 20)
Expand All @@ -40,6 +41,7 @@
#' unified_model <- lightgbm.unify(lgb_model, sparse_data)
#' shaps <- treeshap(unified_model, data[1:2, ])
#' plot_contribution(shaps, obs = 1)
#' }
lightgbm.unify <- function(lgb_model, data, recalculate = FALSE) {
if (!requireNamespace("lightgbm", quietly = TRUE)) {
stop("Package \"lightgbm\" needed for this function to work. Please install it.",
Expand Down
2 changes: 2 additions & 0 deletions R/unify_xgboost.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#' \code{\link{randomForest.unify}} for \code{\link[randomForest:randomForest]{randomForest models}}
#'
#' @examples
#' \donttest{
#' library(xgboost)
#' data <- fifa20$data[colnames(fifa20$data) != 'work_rate']
#' target <- fifa20$target
Expand All @@ -30,6 +31,7 @@
#' unified_model <- xgboost.unify(xgb_model, as.matrix(data))
#' shaps <- treeshap(unified_model, data[1:2,])
#' plot_contribution(shaps, obs = 1)
#' }
#'
xgboost.unify <- function(xgb_model, data, recalculate = FALSE) {
if (!requireNamespace("xgboost", quietly = TRUE)) {
Expand Down
2 changes: 2 additions & 0 deletions man/gbm.unify.Rd

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

2 changes: 2 additions & 0 deletions man/lightgbm.unify.Rd

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

2 changes: 2 additions & 0 deletions man/plot_contribution.Rd

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

2 changes: 2 additions & 0 deletions man/plot_feature_dependence.Rd

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

2 changes: 2 additions & 0 deletions man/plot_interaction.Rd

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

2 changes: 2 additions & 0 deletions man/predict.model_unified.Rd

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

2 changes: 2 additions & 0 deletions man/set_reference_dataset.Rd

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

2 changes: 2 additions & 0 deletions man/xgboost.unify.Rd

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

0 comments on commit 2b8b65c

Please sign in to comment.