diff --git a/DESCRIPTION b/DESCRIPTION index 49adcfd..9a5d885 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: EIX Title: EIX: Explain Interactions in XGBoost Structure mining for XGBoost and LightGBM models -Version: 0.1 +Version: 0.2 Authors@R: c( person("Ewelina", "Karbowiak", email = "ewelina.karbowiak12@gmail.com", role = c("aut", "cre")), person("Przemyslaw", "Biecek", email = "przemyslaw.biecek@gmail.com", role = c("aut","ths")) diff --git a/NAMESPACE b/NAMESPACE index 5ca351e..70f8850 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,7 +9,7 @@ export(lollipop) export(waterfall) import(data.table) import(ggplot2) -importFrom(DALEX,theme_mi2) +importFrom(DALEX,theme_drwhy) importFrom(ggiraphExtra,coord_radar) importFrom(ggrepel,geom_label_repel) importFrom(ggrepel,geom_text_repel) diff --git a/R/lollipop.R b/R/lollipop.R index f819b84..10367db 100644 --- a/R/lollipop.R +++ b/R/lollipop.R @@ -13,6 +13,7 @@ #' @import data.table #' #' @examples +#' options(warn = -1) #' library("EIX") #' library("Matrix") #' sm <- sparse.model.matrix(left ~ . - 1, data = HR_data) diff --git a/R/plot_importance.R b/R/plot_importance.R index 2838dd5..f36432c 100644 --- a/R/plot_importance.R +++ b/R/plot_importance.R @@ -27,6 +27,8 @@ #' six measures of variables' or interactions' importance in the model. #' If FALSE the plot containing two chosen measures #' of variables' or interactions' importance in the model. +#' @param text_start_point place, where the names of the particular feature start. Available for `radar=TRUE`. Range from 0 to 1. Default 0.5. +#' @param text_size size of the text on the plot. Default 3.5. #' @param xmeasure measure on the x-axis.Available for `radar=FALSE`. Default "sumCover". #' @param ymeasure measure on the y-axis. Available for `radar=FALSE`. Default "sumGain". #' @param ... other parameters. @@ -35,7 +37,7 @@ #' #' @import ggplot2 #' @import data.table -#' @importFrom DALEX theme_mi2 +#' @importFrom DALEX theme_drwhy #' @importFrom ggrepel geom_label_repel #' @importFrom ggiraphExtra coord_radar #' @@ -83,7 +85,7 @@ #' @export -plot.importance <- function(x, ..., top = 10, radar = TRUE, +plot.importance <- function(x, ..., top = 10, radar = TRUE, text_start_point = 0.5, text_size=3.5, xmeasure = "sumCover", ymeasure = "sumGain"){ Feature <- sumGain <- sumCover <- meanGain <- meanCover <- @@ -97,7 +99,7 @@ plot.importance <- function(x, ..., top = 10, radar = TRUE, ggplot(data.frame(x[1:top, ]), aes_string(x = xmeasure, y = ymeasure, label = "Feature")) + geom_point() + - scale_size() + geom_label_repel() + theme_mi2() + scale_size() + geom_label_repel() + theme_drwhy() }else{ import <- as.data.table(x[1:top, ]) @@ -108,25 +110,34 @@ plot.importance <- function(x, ..., top = 10, radar = TRUE, meanCover = meanCover / max(import[, meanCover]), mean5Gain = mean5Gain / max(import[, mean5Gain]), frequency = frequency / max(import[, frequency]))] + data<-import[,Feature:= ifelse(nchar(import[,Feature])>20, gsub(":", ": :",import[,Feature]),Feature)] import$Feature <- factor(import$Feature, levels = import$Feature[order(import$sumGain, decreasing = TRUE)]) - data_to_plot <- melt(import, id = 1, measures = 2:6) + + #angles and hjust of labels + numberOfBars=nrow(import) + angle= 90-360*(row(import)[,1]-0.5)/numberOfBars + + import$hjust<-ifelse( angle < -90, 1, 0) + import$angle<-ifelse(angle < -90, angle+180, angle) + + data_to_plot <- melt(import, id = c(1,8,9), measures = 2:6, value.factor = FALSE) + data<-data_to_plot[,.(hjust=mean(hjust),angle=mean(angle)), by=Feature] ggplot(data.frame(data_to_plot), aes(x = Feature, y = value, colour = variable, group = variable)) + geom_line(size = 1.5) + geom_point(size = 2.5) + - theme_mi2() + + theme_drwhy() + theme(axis.title.x = element_blank(), axis.title.y = element_blank(), - #axis.text.x = element_text(angle=45), legend.position = "bottom", - #axis.text.y = element_blank(), panel.grid.major.y = element_line(colour = "gray68", linetype = "dashed", size = 0.4), axis.line = element_blank(), - plot.margin = margin(40, 40, 40, 40)) + - labs(fill = "Measures") + - coord_radar()+ - scale_x_discrete(labels = lapply(strwrap(import[,Feature], width = 10, simplify = FALSE), paste, collapse="\n")) + axis.text.x=element_blank(),) + + labs(fill = "Measures")+ + coord_radar() + + geom_text(data=data, aes(x=Feature, y= rep(text_start_point,top), label=lapply(strwrap(data[,Feature], width = 10, simplify = FALSE), paste, collapse="\n"), hjust=hjust), color="#371ea3", fontface="bold",alpha=0.6, size=text_size, angle= data$angle, inherit.aes = FALSE ) + } } diff --git a/R/plot_interactions.R b/R/plot_interactions.R index 2881092..53683ec 100644 --- a/R/plot_interactions.R +++ b/R/plot_interactions.R @@ -14,7 +14,7 @@ #' #' @import data.table #' @import ggplot2 -#' @importFrom DALEX theme_mi2 +#' @importFrom DALEX theme_drwhy #' #' @examples #' library("EIX") @@ -65,11 +65,11 @@ plot.interactions <- function(x, ...) { ggplot(data.frame(x), aes(Child, Parent, sumGain)) + geom_tile(aes(fill = breaks)) + - theme_mi2() + + theme_drwhy() + theme(axis.text.x = element_text(hjust = 1, angle = 90), axis.text.y = element_text(hjust = 1, angle = 0)) + scale_fill_manual(name = "sumGain", - values = c("#ffffff", "#ccccff", "#7f7fff", "#3232ff"), + values = c("#f4f5ff", "#ccccff", "#7f7fff", "#3232ff"), drop = FALSE, breaks = levels(x$breaks), labels = c("very low", "low", "medium", "high")) + diff --git a/R/plot_lollipop.R b/R/plot_lollipop.R index 6be1719..a3f3bcf 100644 --- a/R/plot_lollipop.R +++ b/R/plot_lollipop.R @@ -7,6 +7,8 @@ #' and variables in the roots (horizontal label) will be displayed, #' if "interactions" then labels for all interactions, #' if "roots" then labels for all variables in the root. +#' @param threshold on the plot will occur only labels with Gain higher than `threshold` of the max Gain value in the model. +#' The lower threshold, the more labels on the plot. Range from 0 to 1. Default 0.1. #' @param log TRUE/FALSE logarithmic scale on the plot. Default TRUE. #' @param ... other parameters. #' @@ -14,11 +16,12 @@ #' #' @import data.table #' @import ggplot2 -#' @importFrom DALEX theme_mi2 +#' @importFrom DALEX theme_drwhy #' @importFrom ggrepel geom_label_repel #' @importFrom ggrepel geom_text_repel #' #' @examples +#' options(warn = -1) #' library("EIX") #' library("Matrix") #' sm <- sparse.model.matrix(left ~ . - 1, data = HR_data) @@ -42,7 +45,7 @@ #' #' @export -plot.lollipop<-function(x, ..., labels = "topAll", log = TRUE){ +plot.lollipop<-function(x, ..., labels = "topAll", log = TRUE, threshold=0.1){ Tree <- Quality <- depth <- Feature <- NULL nodes <- x[[1]] @@ -57,24 +60,23 @@ plot.lollipop<-function(x, ..., labels = "topAll", log = TRUE){ switch(labels, topAll = { p + geom_text_repel(data = data.frame(nodes), - aes(label = ifelse((interaction == TRUE) & (Quality > 0.1 * (max(nodes[, Quality]))), Feature, '')), + aes(label = ifelse((interaction == TRUE) & (Quality > threshold * (max(nodes[, Quality]))), Feature, '')), angle = 90, nudge_y = 0.05, direction = "x", vjust = 0, segment.size = 0.2) + geom_label_repel(data = data.frame(roots), - aes(label = ifelse(Quality > 0.1 * (max(nodes[, Quality] )), Feature, ''))) + aes(label = ifelse(Quality > threshold * (max(nodes[, Quality] )), Feature, ''))) }, interactions = { p + geom_text_repel(data = data.frame(nodes), - aes(label = ifelse(( interaction == TRUE ), Feature, '')), + aes(label = ifelse(( interaction == TRUE ) & (Quality > threshold * (max(nodes[, Quality]))), Feature, '')), angle = 90, nudge_y = 0.05, direction = "x", vjust = 0, segment.size = 0.2 ) }, roots = { - p + geom_label_repel(data = data.frame(roots), aes(label = Feature)) + p + geom_label_repel(data = data.frame(roots), aes(label = ifelse(Quality > threshold * (max(nodes[, Quality])), Feature, ''))) })} - p <- p + theme_mi2() + ylab("Gain") + + p <- p + theme_drwhy()+ ylab("Gain") + scale_shape_discrete("Depth") + scale_colour_discrete("Depth") + if (log) {scale_x_continuous(trans = 'log10')} - p } diff --git a/README.md b/README.md index 01137d6..791367d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A set of tools to explain XGBoost and LightGBM models. Install from GitHub ```{r} -devtools::install_github("ekarbowiak/EIX") +devtools::install_github("ModelOriented/EIX") ``` ## Cheatsheets diff --git a/cheatsheets/EIX.pdf b/cheatsheets/EIX.pdf index 9433298..e5519fd 100644 Binary files a/cheatsheets/EIX.pdf and b/cheatsheets/EIX.pdf differ diff --git a/cheatsheets/EIX.png b/cheatsheets/EIX.png index e7fc371..cfc5529 100644 Binary files a/cheatsheets/EIX.png and b/cheatsheets/EIX.png differ diff --git a/cheatsheets/EIX.pptx b/cheatsheets/EIX.pptx index cd47c24..a194b45 100644 Binary files a/cheatsheets/EIX.pptx and b/cheatsheets/EIX.pptx differ diff --git a/docs/articles/EIX.html b/docs/articles/EIX.html index 686508c..6161196 100644 --- a/docs/articles/EIX.html +++ b/docs/articles/EIX.html @@ -273,18 +273,6 @@

-
# library("lightgbm")
-# 
-# lgb.train.data <- lgb.Dataset(sparse_matrix, label = label)
-# lgb.params = list(objective = "binary",max_depth=4)
-# 
-# lgb.model <- lgb.train(lgb.params, lgb.train.data, 100)
-# library(lightgbm)
-# 
-# lgb.train.data <- lgb.Dataset(sparse_matrix, label = label)
-# lgb.params = list(objective = "binary",max_depth=2)
-# 
-# xgb_model <- lgb.train(lgb.params, lgb.train.data, 100)

Function xgboost::xgb.importance shows importance of single variables. EIX adds new measures of variables’ importance and shows also importance of interactions.

knitr::kable(head(xgboost::xgb.importance(colnames(sparse_matrix),xgb_model)))
@@ -343,8 +331,11 @@

lolli<-lollipop(xgb_model,sparse_matrix)
 plot(lolli)

-
#plot(lolli, labels="roots")
+
#plot(lolli, threshold=0.05)
+#plot(lolli, labels="roots")
 #plot(lolli, labels="interactions")
+#plot(lolli, labels="roots", threshold=0.05)
+#plot(lolli, labels="interactions",threshold=0.05)
 #plot(lolli, log=FALSE)
@@ -434,7 +425,9 @@

The function plot with parameter radar = TRUE enables to compare different measures of variables and interactions importance on the radar plot from ggiraphExtra package. Bellow I attach the example of radar plot. On the outside of the circle there are names of variables or interactions. Colored lines represent various measures of importance. The positions on the plot are sorted decreasing. The variable with the highest sumGain value is on the right of 12 o’clock. Next the sumGain value decreases in a clockwise direction.

plot(importance)

-
#plot(importance, top=15)
+
#plot(importance, text_start_point = 0.3)
+#plot(importance, text_size = 4)
+#plot(importance, top=15)

diff --git a/docs/articles/EIX_files/figure-html/unnamed-chunk-10-1.png b/docs/articles/EIX_files/figure-html/unnamed-chunk-10-1.png index 3173a09..cca1d29 100644 Binary files a/docs/articles/EIX_files/figure-html/unnamed-chunk-10-1.png and b/docs/articles/EIX_files/figure-html/unnamed-chunk-10-1.png differ diff --git a/docs/articles/EIX_files/figure-html/unnamed-chunk-6-1.png b/docs/articles/EIX_files/figure-html/unnamed-chunk-6-1.png index 4d837a3..7d76911 100644 Binary files a/docs/articles/EIX_files/figure-html/unnamed-chunk-6-1.png and b/docs/articles/EIX_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/docs/articles/EIX_files/figure-html/unnamed-chunk-7-1.png b/docs/articles/EIX_files/figure-html/unnamed-chunk-7-1.png index e5b8cc7..3d4219d 100644 Binary files a/docs/articles/EIX_files/figure-html/unnamed-chunk-7-1.png and b/docs/articles/EIX_files/figure-html/unnamed-chunk-7-1.png differ diff --git a/docs/articles/EIX_files/figure-html/unnamed-chunk-8-1.png b/docs/articles/EIX_files/figure-html/unnamed-chunk-8-1.png index 055406a..ffab540 100644 Binary files a/docs/articles/EIX_files/figure-html/unnamed-chunk-8-1.png and b/docs/articles/EIX_files/figure-html/unnamed-chunk-8-1.png differ diff --git a/docs/articles/EIX_files/figure-html/unnamed-chunk-9-1.png b/docs/articles/EIX_files/figure-html/unnamed-chunk-9-1.png index c9485f8..6fba8ca 100644 Binary files a/docs/articles/EIX_files/figure-html/unnamed-chunk-9-1.png and b/docs/articles/EIX_files/figure-html/unnamed-chunk-9-1.png differ diff --git a/docs/index.html b/docs/index.html index 03288e8..8ee7da2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -65,7 +65,7 @@

Installation

Install from GitHub

-
devtools::install_github("ekarbowiak/EIX")
+
devtools::install_github("ModelOriented/EIX")

diff --git a/docs/reference/importance-1.png b/docs/reference/importance-1.png index 6f63926..8cc6a4c 100644 Binary files a/docs/reference/importance-1.png and b/docs/reference/importance-1.png differ diff --git a/docs/reference/importance-2.png b/docs/reference/importance-2.png index 37082a5..25fc9d0 100644 Binary files a/docs/reference/importance-2.png and b/docs/reference/importance-2.png differ diff --git a/docs/reference/importance-3.png b/docs/reference/importance-3.png index 40c57fb..16dcd3c 100644 Binary files a/docs/reference/importance-3.png and b/docs/reference/importance-3.png differ diff --git a/docs/reference/importance-4.png b/docs/reference/importance-4.png index 777c125..9255843 100644 Binary files a/docs/reference/importance-4.png and b/docs/reference/importance-4.png differ diff --git a/docs/reference/importance-5.png b/docs/reference/importance-5.png index 6fba152..2bbcfa2 100644 Binary files a/docs/reference/importance-5.png and b/docs/reference/importance-5.png differ diff --git a/docs/reference/importance-6.png b/docs/reference/importance-6.png index 67ff44a..468932b 100644 Binary files a/docs/reference/importance-6.png and b/docs/reference/importance-6.png differ diff --git a/docs/reference/index.html b/docs/reference/index.html index 4eae1b7..d30f2dc 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ diff --git a/docs/reference/interactions-1.png b/docs/reference/interactions-1.png index 76f3a56..9cb291d 100644 Binary files a/docs/reference/interactions-1.png and b/docs/reference/interactions-1.png differ diff --git a/docs/reference/interactions-2.png b/docs/reference/interactions-2.png index 3b85d26..ee6fe33 100644 Binary files a/docs/reference/interactions-2.png and b/docs/reference/interactions-2.png differ diff --git a/docs/reference/interactions-3.png b/docs/reference/interactions-3.png index 7e72b28..950990b 100644 Binary files a/docs/reference/interactions-3.png and b/docs/reference/interactions-3.png differ diff --git a/docs/reference/interactions-4.png b/docs/reference/interactions-4.png index 313277c..3a6e708 100644 Binary files a/docs/reference/interactions-4.png and b/docs/reference/interactions-4.png differ diff --git a/docs/reference/lollipop-1.png b/docs/reference/lollipop-1.png index 7b47296..50cf202 100644 Binary files a/docs/reference/lollipop-1.png and b/docs/reference/lollipop-1.png differ diff --git a/docs/reference/lollipop-2.png b/docs/reference/lollipop-2.png index e749f1d..4c0bf4a 100644 Binary files a/docs/reference/lollipop-2.png and b/docs/reference/lollipop-2.png differ diff --git a/docs/reference/lollipop.html b/docs/reference/lollipop.html index 8653436..c32de4c 100644 --- a/docs/reference/lollipop.html +++ b/docs/reference/lollipop.html @@ -110,7 +110,8 @@

Value

Examples

-
library("EIX") +
options(warn = -1) +library("EIX") library("Matrix") sm <- sparse.model.matrix(left ~ . - 1, data = HR_data) @@ -119,14 +120,14 @@

Examp xgb_model <- xgboost(sm, params = param, label = HR_data[, left] == 1, nrounds = 50, verbose=0) lolli <- lollipop(xgb_model, sm) -plot(lolli, labels = "topAll", log_scale = TRUE)

#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Removed 7 rows containing missing values (geom_text_repel).
+plot(lolli, labels = "topAll", log_scale = TRUE)
library(lightgbm) train_data <- lgb.Dataset(sm, label = HR_data[, left] == 1) params <- list(objective = "binary", max_depth = 2) lgb_model <- lgb.train(params, train_data, 50) lolli <- lollipop(lgb_model, sm) -plot(lolli, labels = "topAll", log_scale = TRUE)
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Removed 19 rows containing missing values (geom_text_repel).
+plot(lolli, labels = "topAll", log_scale = TRUE)
diff --git a/docs/reference/plot.importance-1.png b/docs/reference/plot.importance-1.png index 6f63926..8cc6a4c 100644 Binary files a/docs/reference/plot.importance-1.png and b/docs/reference/plot.importance-1.png differ diff --git a/docs/reference/plot.importance-2.png b/docs/reference/plot.importance-2.png index 37082a5..25fc9d0 100644 Binary files a/docs/reference/plot.importance-2.png and b/docs/reference/plot.importance-2.png differ diff --git a/docs/reference/plot.importance-3.png b/docs/reference/plot.importance-3.png index 40c57fb..16dcd3c 100644 Binary files a/docs/reference/plot.importance-3.png and b/docs/reference/plot.importance-3.png differ diff --git a/docs/reference/plot.importance-4.png b/docs/reference/plot.importance-4.png index 74952a0..f0a19de 100644 Binary files a/docs/reference/plot.importance-4.png and b/docs/reference/plot.importance-4.png differ diff --git a/docs/reference/plot.importance-5.png b/docs/reference/plot.importance-5.png index 6fba152..2bbcfa2 100644 Binary files a/docs/reference/plot.importance-5.png and b/docs/reference/plot.importance-5.png differ diff --git a/docs/reference/plot.importance-6.png b/docs/reference/plot.importance-6.png index 0ef572e..b22c7c9 100644 Binary files a/docs/reference/plot.importance-6.png and b/docs/reference/plot.importance-6.png differ diff --git a/docs/reference/plot.importance.html b/docs/reference/plot.importance.html index 22c2c67..f5ba5e5 100644 --- a/docs/reference/plot.importance.html +++ b/docs/reference/plot.importance.html @@ -90,7 +90,8 @@

Plot importance measures

# S3 method for importance
 plot(x, ..., top = 10, radar = TRUE,
-  xmeasure = "sumCover", ymeasure = "sumGain")
+ text_start_point = 0.5, text_size = 3.5, xmeasure = "sumCover", + ymeasure = "sumGain")

Arguments

@@ -114,6 +115,14 @@

Ar If FALSE the plot containing two chosen measures of variables' or interactions' importance in the model.

+

+ + + + + + + @@ -340,7 +349,7 @@

Examp #> 4: 120.7 2228 26 303.5 #> 5: 223.3 3042 10 331.0 #> 6: 124.0 3750 3 124.0 -#> 7: 101.1 3208 1 101.1
plot(imp, top = 10, radar = FALSE, xmeasure = "sumCover", ymeasure = "sumGain")
#> Warning: Removed 3 rows containing missing values (geom_point).
#> Warning: Removed 3 rows containing missing values (geom_label_repel).
+#> 7: 101.1 3208 1 101.1
plot(imp, top = 10, radar = FALSE, xmeasure = "sumCover", ymeasure = "sumGain")
diff --git a/docs/reference/plot.interactions-1.png b/docs/reference/plot.interactions-1.png index 76f3a56..9cb291d 100644 Binary files a/docs/reference/plot.interactions-1.png and b/docs/reference/plot.interactions-1.png differ diff --git a/docs/reference/plot.interactions-2.png b/docs/reference/plot.interactions-2.png index 3b85d26..ee6fe33 100644 Binary files a/docs/reference/plot.interactions-2.png and b/docs/reference/plot.interactions-2.png differ diff --git a/docs/reference/plot.interactions-3.png b/docs/reference/plot.interactions-3.png index 7e72b28..950990b 100644 Binary files a/docs/reference/plot.interactions-3.png and b/docs/reference/plot.interactions-3.png differ diff --git a/docs/reference/plot.interactions-4.png b/docs/reference/plot.interactions-4.png index 313277c..3a6e708 100644 Binary files a/docs/reference/plot.interactions-4.png and b/docs/reference/plot.interactions-4.png differ diff --git a/docs/reference/plot.lollipop-1.png b/docs/reference/plot.lollipop-1.png index a52dbd0..a27868f 100644 Binary files a/docs/reference/plot.lollipop-1.png and b/docs/reference/plot.lollipop-1.png differ diff --git a/docs/reference/plot.lollipop-2.png b/docs/reference/plot.lollipop-2.png index f37e316..ca6770c 100644 Binary files a/docs/reference/plot.lollipop-2.png and b/docs/reference/plot.lollipop-2.png differ diff --git a/docs/reference/plot.lollipop.html b/docs/reference/plot.lollipop.html index e487a2e..6a735ee 100644 --- a/docs/reference/plot.lollipop.html +++ b/docs/reference/plot.lollipop.html @@ -87,7 +87,8 @@

Visualiation of the model

# S3 method for lollipop
-plot(x, ..., labels = "topAll", log = TRUE)
+plot(x, ..., labels = "topAll", log = TRUE, + threshold = 0.1)

Arguments

text_start_point

place, where the names of the particular feature start. Available for `radar=TRUE`. Range from 0 to 1. Default 0.5.

text_size

size of the text on the plot. Default 3.5.

xmeasure

measure on the x-axis.Available for `radar=FALSE`. Default "sumCover".

@@ -111,6 +112,11 @@

Ar

+ + + +
log

TRUE/FALSE logarithmic scale on the plot. Default TRUE.

threshold

on the plot will occur only labels with Gain higher than `threshold` of the max Gain value in the model. +The lower threshold, the more labels on the plot. Range from 0 to 1. Default 0.1.

Value

@@ -119,7 +125,8 @@

Value

Examples

-
library("EIX") +
options(warn = -1) +library("EIX") library("Matrix") sm <- sparse.model.matrix(left ~ . - 1, data = HR_data) @@ -128,14 +135,14 @@

Examp xgb_model <- xgboost(sm, params = param, label = HR_data[, left] == 1, nrounds = 50, verbose=0) lolli <- lollipop(xgb_model, sm) -plot(lolli, labels = "topAll", log_scale = TRUE)

#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Removed 7 rows containing missing values (geom_text_repel).
+plot(lolli, labels = "topAll", log_scale = TRUE)
library(lightgbm) train_data <- lgb.Dataset(sm, label = HR_data[, left] == 1) params <- list(objective = "binary", max_depth = 3) lgb_model <- lgb.train(params, train_data, 50) lolli <- lollipop(lgb_model, sm) -plot(lolli, labels = "topAll", log_scale = TRUE)
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Transformation introduced infinite values in continuous x-axis
#> Warning: Removed 15 rows containing missing values (geom_text_repel).
+plot(lolli, labels = "topAll", log_scale = TRUE)