bgreenwell / fastshap

Fast approximate Shapley values in R
https://bgreenwell.github.io/fastshap/
112 stars 18 forks source link

Visualization omitted, Javascript library not loaded #55

Closed zhaoliang0302 closed 1 year ago

zhaoliang0302 commented 1 year ago

Hi, I followed the example code in the fastshap vignette and encountered with error:

library(fastshap)
library(xgboost)

data(boston, package = "pdp")
X <- data.matrix(subset(boston, select = -cmedv))  # matrix of feature values

set.seed(859)  # for reproducibility
bst <- xgboost(X, label = boston$cmedv, nrounds = 338, max_depth = 3, eta = 0.1,
               verbose = 0)

ex <- explain(bst, exact = TRUE, X = X)

force_plot(object = ex[1L, ], feature_values = X[1L, ], display = "html")  

Error:

 <b>Visualization omitted, Javascript library not loaded!</b><br>
  Have you run `initjs()` in this notebook? If this notebook was from another
  user you must also trust this notebook (File -> Trust notebook). If you are viewing
  this notebook on github the Javascript has been stripped for security. If you are using
  JupyterLab this error is because a JupyterLab extension has not yet been written.

Here is my working environment:

sessionInfo()
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936 
[2] LC_CTYPE=Chinese (Simplified)_China.936   
[3] LC_MONETARY=Chinese (Simplified)_China.936
[4] LC_NUMERIC=C                              
[5] LC_TIME=Chinese (Simplified)_China.936    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] xgboost_1.6.0.1 fastshap_0.0.7 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9        pillar_1.7.0      compiler_4.2.1    tools_4.2.1      
 [5] digest_0.6.29     jsonlite_1.8.4    lifecycle_1.0.3   tibble_3.1.8     
 [9] gtable_0.3.1      lattice_0.20-45   pkgconfig_2.0.3   png_0.1-8        
[13] rlang_1.0.6       Matrix_1.5-3      DBI_1.1.2         cli_3.4.1        
[17] rstudioapi_0.13   fastmap_1.1.0     gridExtra_2.3     dplyr_1.0.10     
[21] rappdirs_0.3.3    generics_0.1.2    vctrs_0.5.0       rprojroot_2.0.3  
[25] grid_4.2.1        tidyselect_1.2.0  reticulate_1.26   glue_1.6.2       
[29] data.table_1.14.4 here_1.0.1        R6_2.5.1          fansi_0.5.0      
[33] ggplot2_3.4.0     magrittr_2.0.3    htmltools_0.5.3   scales_1.2.1     
[37] ellipsis_0.3.2    assertthat_0.2.1  colorspace_2.0-3  utf8_1.2.2       
[41] munsell_0.5.0     crayon_1.5.1
bgreenwell commented 1 year ago

Hi @zhaoliang0302, sorry for the late reply. All plotting functions have been removed in the next release in favor of using the far superior shapviz library.