diff --git a/.Rbuildignore b/.Rbuildignore index 912e353..813c757 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -13,3 +13,4 @@ ^slowtests$ ^TODO\.md$ ^vignettes$ +^\.github$ diff --git a/.Rproj.user/34EA04DA/cpp-definition-cache b/.Rproj.user/34EA04DA/cpp-definition-cache index 8611e96..e5633c8 100644 --- a/.Rproj.user/34EA04DA/cpp-definition-cache +++ b/.Rproj.user/34EA04DA/cpp-definition-cache @@ -1,26 +1,26 @@ [ { - "definitions" : [ + "file": "/Users/b780620/Desktop/devel/fastshap/src/fastshap.cpp", + "file_last_write": 1564258833.0, + "definitions": [ { - "column" : 15, - "file" : "/Users/b780620/Desktop/devel/fastshap/src/fastshap.cpp", - "kind" : 6, - "line" : 6, - "name" : "genOMat(int, int)", - "parent_name" : "", - "usr" : "c:@F@genOMat#I#I#" + "usr": "c:@F@genOMat#I#I#", + "kind": 6, + "parent_name": "", + "name": "genOMat(int, int)", + "file": "/Users/b780620/Desktop/devel/fastshap/src/fastshap.cpp", + "line": 6, + "column": 15 }, { - "column" : 6, - "file" : "/Users/b780620/Desktop/devel/fastshap/src/fastshap.cpp", - "kind" : 6, - "line" : 52, - "name" : "genFrankensteinMatrices(arma::mat, arma::mat, arma::umat, int)", - "parent_name" : "", - "usr" : "c:@F@genFrankensteinMatrices#$@N@arma@S@Mat>#d#S0_#$@N@arma@S@Mat>#i#I#" + "usr": "c:@F@genFrankensteinMatrices#$@N@arma@S@Mat>#d#S0_#$@N@arma@S@Mat>#i#I#", + "kind": 6, + "parent_name": "", + "name": "genFrankensteinMatrices(arma::mat, arma::mat, arma::umat, int)", + "file": "/Users/b780620/Desktop/devel/fastshap/src/fastshap.cpp", + "line": 52, + "column": 6 } - ], - "file" : "/Users/b780620/Desktop/devel/fastshap/src/fastshap.cpp", - "file_last_write" : 1564258833.000000 + ] } ] \ No newline at end of file diff --git a/.Rproj.user/34EA04DA/pcs/debug-breakpoints.pper b/.Rproj.user/34EA04DA/pcs/debug-breakpoints.pper index 5528aea..4893a8a 100644 --- a/.Rproj.user/34EA04DA/pcs/debug-breakpoints.pper +++ b/.Rproj.user/34EA04DA/pcs/debug-breakpoints.pper @@ -1,6 +1,5 @@ { - "debugBreakpointsState" : { - "breakpoints" : [ - ] + "debugBreakpointsState": { + "breakpoints": [] } } \ No newline at end of file diff --git a/.Rproj.user/34EA04DA/pcs/files-pane.pper b/.Rproj.user/34EA04DA/pcs/files-pane.pper index 8285d1e..acf9d82 100644 --- a/.Rproj.user/34EA04DA/pcs/files-pane.pper +++ b/.Rproj.user/34EA04DA/pcs/files-pane.pper @@ -1,9 +1,9 @@ { - "path" : "~/Desktop/devel/fastshap", - "sortOrder" : [ + "path": "~/Desktop/devel/fastshap", + "sortOrder": [ { - "ascending" : true, - "columnIndex" : 2 + "columnIndex": 2, + "ascending": true } ] } \ No newline at end of file diff --git a/.Rproj.user/34EA04DA/pcs/source-pane.pper b/.Rproj.user/34EA04DA/pcs/source-pane.pper index 9efb51b..b074a4f 100644 --- a/.Rproj.user/34EA04DA/pcs/source-pane.pper +++ b/.Rproj.user/34EA04DA/pcs/source-pane.pper @@ -1,3 +1,3 @@ { - "activeTab" : -1 + "activeTab": 1 } \ No newline at end of file diff --git a/.Rproj.user/34EA04DA/pcs/windowlayoutstate.pper b/.Rproj.user/34EA04DA/pcs/windowlayoutstate.pper index e9addde..25493b6 100644 --- a/.Rproj.user/34EA04DA/pcs/windowlayoutstate.pper +++ b/.Rproj.user/34EA04DA/pcs/windowlayoutstate.pper @@ -1,14 +1,14 @@ { - "left" : { - "panelheight" : 1349, - "splitterpos" : 549, - "topwindowstate" : "HIDE", - "windowheight" : 1386 + "left": { + "splitterpos": 378, + "topwindowstate": "MAXIMIZE", + "panelheight": 929, + "windowheight": 966 }, - "right" : { - "panelheight" : 1348, - "splitterpos" : 691, - "topwindowstate" : "NORMAL", - "windowheight" : 1386 + "right": { + "splitterpos": 475, + "topwindowstate": "NORMAL", + "panelheight": 928, + "windowheight": 966 } } \ No newline at end of file diff --git a/.Rproj.user/34EA04DA/pcs/workbench-pane.pper b/.Rproj.user/34EA04DA/pcs/workbench-pane.pper index 863d0d0..07157f3 100644 --- a/.Rproj.user/34EA04DA/pcs/workbench-pane.pper +++ b/.Rproj.user/34EA04DA/pcs/workbench-pane.pper @@ -1,6 +1,5 @@ { - "TabSet1" : 0, - "TabSet2" : 6, - "TabZoom" : { - } + "TabSet1": 0, + "TabSet2": 4, + "TabZoom": {} } \ No newline at end of file diff --git a/.Rproj.user/34EA04DA/persistent-state b/.Rproj.user/34EA04DA/persistent-state index 4627cee..120c4e5 100644 --- a/.Rproj.user/34EA04DA/persistent-state +++ b/.Rproj.user/34EA04DA/persistent-state @@ -1,8 +1,8 @@ build-last-errors="[]" build-last-errors-base-dir="~/Desktop/devel/fastshap/" -build-last-outputs="[{\"output\":\"==> Rcpp::compileAttributes()\\n\\n\",\"type\":0},{\"output\":\"* Updated R/RcppExports.R\\n\",\"type\":1},{\"output\":\"\\n\",\"type\":1},{\"output\":\"==> devtools::document(roclets = c('rd', 'collate', 'namespace'))\\n\\n\",\"type\":0},{\"output\":\"Updating fastshap documentation\\n\",\"type\":2},{\"output\":\"Warning: Version of roxygen2 last used with this package is 7.0.2. You only have version 6.1.1\\n\",\"type\":2},{\"output\":\"Writing NAMESPACE\\n\",\"type\":1},{\"output\":\"Loading fastshap\\n\",\"type\":2},{\"output\":\"Writing NAMESPACE\\n\",\"type\":1},{\"output\":\"Warning message:\\nroxygen2 requires Encoding: UTF-8 \\n\",\"type\":2},{\"output\":\"Documentation completed\\n\\n\",\"type\":1},{\"output\":\"==> R CMD INSTALL --preclean --no-multiarch --with-keep.source fastshap\\n\\n\",\"type\":0},{\"output\":\"* installing to library ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library’\\n\",\"type\":1},{\"output\":\"* installing *source* package ‘fastshap’ ...\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"clang++ -std=gnu++11 -I\\\"/Library/Frameworks/R.framework/Resources/include\\\" -DNDEBUG -I\\\"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include\\\" -I\\\"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppArmadillo/include\\\" -I/usr/local/include -DARMA_DONT_USE_OPENMP -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** libs\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"clang++ -std=gnu++11 -I\\\"/Library/Frameworks/R.framework/Resources/include\\\" -DNDEBUG -I\\\"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include\\\" -I\\\"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppArmadillo/include\\\" -I/usr/local/include -DARMA_DONT_USE_OPENMP -fPIC -Wall -g -O2 -c fastshap.cpp -o fastshap.o\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"clang++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o fastshap.so RcppExports.o fastshap.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/Cellar/gcc/9.2.0_3/lib/gcc/9 -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"installing to /Library/Frameworks/R.framework/Versions/3.5/Resources/library/fastshap/libs\\n\",\"type\":1},{\"output\":\"** R\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** inst\\n\",\"type\":1},{\"output\":\"** byte-compile and prepare package for lazy loading\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** help\\n\",\"type\":1},{\"output\":\"*** installing help indices\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"*** copying figures\\n\",\"type\":1},{\"output\":\"** building package indices\\n\",\"type\":1},{\"output\":\"** testing if installed package can be loaded\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"* DONE (fastshap)\\n\",\"type\":1},{\"output\":\"\",\"type\":1}]" -compile_pdf_state="{\"errors\":[],\"output\":\"\",\"running\":false,\"tab_visible\":false,\"target_file\":\"\"}" +build-last-outputs="[{\"type\":0,\"output\":\"==> Rcpp::compileAttributes()\\n\\n\"},{\"type\":1,\"output\":\"* Updated R/RcppExports.R\\n\"},{\"type\":1,\"output\":\"\\n\"},{\"type\":0,\"output\":\"==> devtools::document(roclets = c('rd', 'collate', 'namespace'))\\n\\n\"},{\"type\":2,\"output\":\"Updating fastshap documentation\\n\"},{\"type\":2,\"output\":\"Loading fastshap\\n\"},{\"type\":1,\"output\":\"Writing NAMESPACE\\n\"},{\"type\":1,\"output\":\"Writing NAMESPACE\\n\"},{\"type\":2,\"output\":\"Warning message:\\nroxygen2 requires Encoding: UTF-8 \\n\"},{\"type\":1,\"output\":\"Documentation completed\\n\\n\"},{\"type\":0,\"output\":\"==> R CMD INSTALL --preclean --no-multiarch --with-keep.source fastshap\\n\\n\"},{\"type\":1,\"output\":\"* installing to library ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library’\\n\"},{\"type\":1,\"output\":\"* installing *source* package ‘fastshap’ ...\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** using staged installation\\n\"},{\"type\":1,\"output\":\"** libs\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I\\\"/Library/Frameworks/R.framework/Resources/include\\\" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include' -I/usr/local/include -DARMA_DONT_USE_OPENMP -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I\\\"/Library/Frameworks/R.framework/Resources/include\\\" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include' -I/usr/local/include -DARMA_DONT_USE_OPENMP -fPIC -Wall -g -O2 -c fastshap.cpp -o fastshap.o\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"clang++ -mmacosx-version-min=10.13 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o fastshap.so RcppExports.o fastshap.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/Cellar/gcc/9.2.0_3/lib/gcc/9 -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"installing to /Library/Frameworks/R.framework/Versions/4.0/Resources/library/00LOCK-fastshap/00new/fastshap/libs\\n\"},{\"type\":1,\"output\":\"** R\\n\"},{\"type\":1,\"output\":\"** inst\\n\"},{\"type\":1,\"output\":\"** byte-compile and prepare package for lazy loading\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** help\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"*** installing help indices\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"*** copying figures\\n\"},{\"type\":1,\"output\":\"** building package indices\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** testing if installed package can be loaded from temporary location\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** checking absolute paths in shared objects and dynamic libraries\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** testing if installed package can be loaded from final location\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** testing if installed package keeps a record of temporary installation path\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"* DONE (fastshap)\\n\"},{\"type\":1,\"output\":\"\"}]" +compile_pdf_state="{\"tab_visible\":false,\"running\":false,\"target_file\":\"\",\"output\":\"\",\"errors\":[]}" files.monitored-path="" -find-in-files-state="{\"handle\":\"\",\"input\":\"\",\"path\":\"\",\"regex\":true,\"results\":{\"file\":[],\"line\":[],\"lineValue\":[],\"matchOff\":[],\"matchOn\":[]},\"running\":false}" +find-in-files-state="{\"handle\":\"\",\"input\":\"\",\"path\":\"\",\"regex\":false,\"ignoreCase\":false,\"results\":{\"file\":[],\"line\":[],\"lineValue\":[],\"matchOn\":[],\"matchOff\":[],\"replaceMatchOn\":[],\"replaceMatchOff\":[]},\"running\":false,\"replace\":false,\"preview\":false,\"gitFlag\":false,\"replacePattern\":\"\"}" imageDirtyState="1" saveActionState="0" diff --git a/.Rproj.user/34EA04DA/rmd-outputs b/.Rproj.user/34EA04DA/rmd-outputs index 17487b4..25146a9 100644 --- a/.Rproj.user/34EA04DA/rmd-outputs +++ b/.Rproj.user/34EA04DA/rmd-outputs @@ -1,5 +1,5 @@ /private/var/folders/24/k1n3dpcd2p5glqf8r4232qqc8k86md/T/Rtmpnjvf0L/preview-1810747ca5310.dir/fastshap.html -/private/var/folders/24/k1n3dpcd2p5glqf8r4232qqc8k86md/T/Rtmpnjvf0L/preview-1810734136442.dir/fastshap-vs-shap.html +~/Desktop/gotran/README.html /private/var/folders/24/k1n3dpcd2p5glqf8r4232qqc8k86md/T/Rtmpnjvf0L/preview-18107651b43c3.dir/fastshap-vs-iml-iBreakDown.html /private/var/folders/24/k1n3dpcd2p5glqf8r4232qqc8k86md/T/Rtmpnjvf0L/preview-1810724c568cd.dir/forceplot.html /private/var/folders/24/k1n3dpcd2p5glqf8r4232qqc8k86md/T/Rtmpnjvf0L/preview-181071c637d97.dir/forceplot.html diff --git a/.Rproj.user/34EA04DA/sources/prop/3AF07C6D b/.Rproj.user/34EA04DA/sources/prop/3AF07C6D index bc50256..e730e09 100644 --- a/.Rproj.user/34EA04DA/sources/prop/3AF07C6D +++ b/.Rproj.user/34EA04DA/sources/prop/3AF07C6D @@ -1,4 +1,6 @@ { - "cursorPosition" : "3,14", - "scrollLine" : "0" + "cursorPosition": "3,19", + "scrollLine": "0", + "source_window_id": "", + "Source": "Source" } \ No newline at end of file diff --git a/.Rproj.user/34EA04DA/sources/prop/41B40DB8 b/.Rproj.user/34EA04DA/sources/prop/41B40DB8 index 956187a..9246085 100644 --- a/.Rproj.user/34EA04DA/sources/prop/41B40DB8 +++ b/.Rproj.user/34EA04DA/sources/prop/41B40DB8 @@ -1,5 +1,7 @@ { - "cursorPosition" : "38,3", - "ignored_words" : "TreeSHAP,Shapley,fastshap,nsim,Lundberg,Su,https,arxiv,md,Rmd,GitHub,Shap,plyr,backend,foreach,TreeExplainer,XGBoost,xgboost,iml,img,src,png,Christoph,Interpretable,christophm,github,io,interpretable,travis,ci,bgreenwell,codecov,gh,bottomright,subsetting,Strumbelj,Kononenko\n", - "scrollLine" : "5" + "cursorPosition": "17,46", + "ignored_words": "TreeSHAP,Shapley,fastshap,nsim,Lundberg,Su,https,arxiv,md,Rmd,GitHub,Shap,plyr,backend,foreach,TreeExplainer,XGBoost,xgboost,iml,img,src,png,Christoph,Interpretable,christophm,github,io,interpretable,travis,ci,bgreenwell,codecov,gh,bottomright,subsetting,Strumbelj,Kononenko\n", + "scrollLine": "14", + "source_window_id": "", + "Source": "Source" } \ No newline at end of file diff --git a/.Rproj.user/34EA04DA/sources/prop/INDEX b/.Rproj.user/34EA04DA/sources/prop/INDEX index a985947..e55b8ef 100644 --- a/.Rproj.user/34EA04DA/sources/prop/INDEX +++ b/.Rproj.user/34EA04DA/sources/prop/INDEX @@ -39,6 +39,7 @@ ~%2FDesktop%2Fdevel%2Ffastshap%2Finst%2Ftinytest%2Ftest_force_plot.R="1A9796F1" ~%2FDesktop%2Fdevel%2Ffastshap%2Flogo-fastshap.R="86C25029" ~%2FDesktop%2Fdevel%2Ffastshap%2Fman%2Ffastshap-package.Rd="192533F6" +~%2FDesktop%2Fdevel%2Ffastshap%2Fman%2Flogo-fastshap.svg="12D190CC" ~%2FDesktop%2Fdevel%2Ffastshap%2Fnotebooks%2Fbibliography.bib="FC2A6186" ~%2FDesktop%2Fdevel%2Ffastshap%2Fnotebooks%2Ffastshap-comparison.R="3FC07AE7" ~%2FDesktop%2Fdevel%2Ffastshap%2Fnotebooks%2Ffastshap-comparison.Rmd="A8385697" @@ -85,6 +86,7 @@ ~%2FDesktop%2Fdevel%2Fvip%2FR%2Fvi_permute.R="5414ABD5" ~%2FDesktop%2Ffastshap-adjust.R="D7D37C8C" ~%2FDesktop%2Fforceplot.R="6C1303D7" +~%2FDesktop%2Fgotran%2FREADME.md="7FFEC7BA" ~%2FDesktop%2Fmatrix-subsetting-benchmarks.cpp="1B9A1FA5" ~%2FDesktop%2Fold-Makevars.makefile="FD30FAF0" ~%2FDesktop%2Ftest_fastshap.R="102220BC" diff --git a/.Rproj.user/shared/notebooks/9999330F-README/1/s/chunks.json b/.Rproj.user/shared/notebooks/9999330F-README/1/s/chunks.json index 328e7f7..e871beb 100644 --- a/.Rproj.user/shared/notebooks/9999330F-README/1/s/chunks.json +++ b/.Rproj.user/shared/notebooks/9999330F-README/1/s/chunks.json @@ -1 +1 @@ -{"chunk_definitions":[],"doc_write_time":1575384935} \ No newline at end of file +{"chunk_definitions":[],"doc_write_time":1614010279} \ No newline at end of file diff --git a/.Rproj.user/shared/notebooks/paths b/.Rproj.user/shared/notebooks/paths index 012e413..f443dc2 100644 --- a/.Rproj.user/shared/notebooks/paths +++ b/.Rproj.user/shared/notebooks/paths @@ -3,7 +3,6 @@ /Users/b780620/Desktop/devel/fastshap/.Rbuildignore="9D5980A4" /Users/b780620/Desktop/devel/fastshap/.gitattributes="1590E2AD" /Users/b780620/Desktop/devel/fastshap/.gitignore="7E490EEC" -/Users/b780620/Desktop/devel/fastshap/.travis.yml="2720CBBB" /Users/b780620/Desktop/devel/fastshap/DESCRIPTION="AD1517C7" /Users/b780620/Desktop/devel/fastshap/NAMESPACE="BF528FAD" /Users/b780620/Desktop/devel/fastshap/NEWS.md="7A48BA2E" @@ -26,6 +25,7 @@ /Users/b780620/Desktop/devel/fastshap/inst/tinytest/test_fastshap_matrix.R="65E9EB44" /Users/b780620/Desktop/devel/fastshap/inst/tinytest/test_fastshap_titanic.R="DE7B49F6" /Users/b780620/Desktop/devel/fastshap/inst/tinytest/test_force_plot.R="55C2401A" +/Users/b780620/Desktop/devel/fastshap/man/logo-fastshap.svg="2F2C24E4" /Users/b780620/Desktop/devel/fastshap/rjournal/greenwell.Rmd="5B4336F7" /Users/b780620/Desktop/devel/fastshap/slowtests/fastshap-ames.R="138A8419" /Users/b780620/Desktop/devel/fastshap/slowtests/fastshap-benchmarks.R="C70C0C1C" diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..243c87b --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,86 @@ +# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. +# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: windows-latest, r: 'release'} + - {os: macOS-latest, r: 'release'} + - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + + env: + R_REMOTES_NO_ERRORS_FROM_WARNINGS: true + RSPM: ${{ matrix.config.rspm }} + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@v1 + with: + r-version: ${{ matrix.config.r }} + + - uses: r-lib/actions/setup-pandoc@v1 + + - name: Query dependencies + run: | + install.packages('remotes') + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) + writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") + shell: Rscript {0} + + - name: Cache R packages + if: runner.os != 'Windows' + uses: actions/cache@v2 + with: + path: ${{ env.R_LIBS_USER }} + key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} + restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + + - name: Install system dependencies + if: runner.os == 'Linux' + run: | + while read -r cmd + do + eval sudo $cmd + done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') + + - name: Install dependencies + run: | + remotes::install_deps(dependencies = TRUE) + remotes::install_cran("rcmdcheck") + shell: Rscript {0} + + - name: Check + env: + _R_CHECK_CRAN_INCOMING_REMOTE_: false + run: | + options(crayon.enabled = TRUE) + rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") + shell: Rscript {0} + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@main + with: + name: ${{ runner.os }}-r${{ matrix.config.r }}-results + path: check diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ba93bef..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r - -language: R -sudo: false -cache: packages - -r: -- oldrel -- release -- devel - -env: - global: - - _R_CHECK_FORCE_SUGGESTS_=false - -r_build_args: "--no-build-vignettes" - -r_check_args: "--no-vignettes" - -after_success: - - Rscript -e 'covr::codecov()' diff --git a/DESCRIPTION b/DESCRIPTION index b018703..aa023c4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: fastshap Type: Package Title: Fast Approximate Shapley Values -Version: 0.0.5 +Version: 0.0.5.9000 Authors@R: person("Brandon", "Greenwell", email = "greenwell.brandon@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-8120-0084")) Description: Computes fast (relative to other implementations) approximate @@ -36,4 +36,4 @@ Suggests: LinkingTo: Rcpp, RcppArmadillo -RoxygenNote: 7.0.2 +RoxygenNote: 7.1.1 diff --git a/NEWS.md b/NEWS.md index a4da1b0..e374616 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,13 @@ +# fastshap 0.0.5.9000 + +## Bug fixes + +* The `force_plot()` function should now be compatible with **shap** (>=0.36.0); thanks to @hfshr and @jbwoillard for reporting [(#12)](https://github.com/bgreenwell/fastshap/issues/12). + +## Miscellaneous + +* Switched from Travis-CI to GitHub Actions for continuous integration. + # fastshap 0.0.5 ## Bug fixes diff --git a/R/autoplot.R b/R/autoplot.R index 84878e2..e31ae1e 100644 --- a/R/autoplot.R +++ b/R/autoplot.R @@ -24,6 +24,11 @@ #' @param X A matrix-like R object (e.g., a data frame or matrix) containing #' ONLY the feature columns from the training data. #' +#' @param feature_values A matrix-like R object (e.g., a data frame or matrix) +#' containing the feature values correposnding to the instance being explained. +#' Only used when \code{type = "dependence"}. \strong{NOTE:} Must contain the +#' same column structure (e.g., column names, order, etc.) as \code{X}. +#' #' @param color_by Character string specifying an optional feature column in #' \code{X} to use for coloring whenever \code{type = "dependence"}. #' @@ -93,6 +98,7 @@ autoplot.explain <- function( feature = NULL, num_features = NULL, X = NULL, + feature_values = NULL, color_by = NULL, smooth = FALSE, smooth_color = "red", @@ -177,6 +183,22 @@ autoplot.explain <- function( if (is.null(row_num)) { row_num <- 1L } + if (!is.null(feature_values)) { + if (ncol(feature_values) != ncol(object)) { + stop("`feature_values` should contain the same number of columns as `X`.", + call. = FALSE) + } + if (!identical(names(feature_values), names(object))) { + stop("`feature_values` should contain the same column names as `X`.", + call. = FALSE) + } + if (nrow(feature_values) > 1) { + stop("`feature_values` must contain a single row.", call. = FALSE) + } + names(object) <- paste0(names(feature_values), " = ", + # data.matrix(feature_values)) + as.matrix(feature_values)) + } shap_con <- data.frame( Variable = names(object), Shapley = t(object[row_num, , drop = TRUE]) diff --git a/R/force_plot.R b/R/force_plot.R index 6501c9d..60c0bca 100644 --- a/R/force_plot.R +++ b/R/force_plot.R @@ -121,8 +121,15 @@ force_plot.explain <- function(object, baseline = NULL, feature_values = NULL, ) # Display results + # FIXME: Is this the best way to determine/compare Python package versions? + shap_version <- reticulate::py_get_attr(shap, name = "__version__") + shap_version <- package_version(as.character(shap_version)) tfile <- tempfile(fileext = ".html") - shap$save_html(tfile, plot_html = fp) + if (shap_version < "0.36.0") { + shap$save_html(tfile, plot_html = fp) + } else { + shap$save_html(tfile, plot = fp) + } display <- match.arg(display) # Check for dependencies if (display == "viewer") { diff --git a/README.Rmd b/README.Rmd index e4cfce8..6b1f1c5 100644 --- a/README.Rmd +++ b/README.Rmd @@ -15,12 +15,11 @@ knitr::opts_chunk$set( warning = FALSE ) ``` -# fastshap +# fastshap [![CRAN status](https://www.r-pkg.org/badges/version/fastshap)](https://CRAN.R-project.org/package=fastshap) -[![Travis build status](https://travis-ci.org/bgreenwell/fastshap.svg?branch=master)](https://travis-ci.org/bgreenwell/fastshap) -[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/bgreenwell/fastshap?branch=master&svg=true)](https://ci.appveyor.com/project/bgreenwell/fastshap) +[![R-CMD-check](https://github.com/bgreenwell/fastshap/workflows/R-CMD-check/badge.svg)](https://github.com/bgreenwell/fastshap/actions) [![Codecov test coverage](https://codecov.io/gh/bgreenwell/fastshap/branch/master/graph/badge.svg)](https://codecov.io/gh/bgreenwell/fastshap?branch=master) [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) diff --git a/README.md b/README.md index ef882be..3abd9e8 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,13 @@ -# fastshap +# fastshap [![CRAN status](https://www.r-pkg.org/badges/version/fastshap)](https://CRAN.R-project.org/package=fastshap) -[![Travis build -status](https://travis-ci.org/bgreenwell/fastshap.svg?branch=master)](https://travis-ci.org/bgreenwell/fastshap) -[![AppVeyor build -status](https://ci.appveyor.com/api/projects/status/github/bgreenwell/fastshap?branch=master&svg=true)](https://ci.appveyor.com/project/bgreenwell/fastshap) +[![R-CMD-check](https://github.com/bgreenwell/fastshap/workflows/R-CMD-check/badge.svg)](https://github.com/bgreenwell/fastshap/actions) [![Codecov test coverage](https://codecov.io/gh/bgreenwell/fastshap/branch/master/graph/badge.svg)](https://codecov.io/gh/bgreenwell/fastshap?branch=master) [![Lifecycle: diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 3a75e16..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,52 +0,0 @@ -# DO NOT CHANGE the "init" and "install" sections below - -# Download script file from GitHub -init: - ps: | - $ErrorActionPreference = "Stop" - Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" - Import-Module '..\appveyor-tool.ps1' - -install: - ps: Bootstrap - -cache: - - C:\RLibrary - -environment: - NOT_CRAN: true - # env vars that may need to be set, at least temporarily, from time to time - # see https://github.com/krlmlr/r-appveyor#readme for details - # USE_RTOOLS: true - # R_REMOTES_STANDALONE: true - -# Adapt as necessary starting from here - -build_script: - - travis-tool.sh install_deps - -test_script: - - travis-tool.sh run_tests - -on_failure: - - 7z a failure.zip *.Rcheck\* - - appveyor PushArtifact failure.zip - -artifacts: - - path: '*.Rcheck\**\*.log' - name: Logs - - - path: '*.Rcheck\**\*.out' - name: Logs - - - path: '*.Rcheck\**\*.fail' - name: Logs - - - path: '*.Rcheck\**\*.Rout' - name: Logs - - - path: '\*_*.tar.gz' - name: Bits - - - path: '\*_*.zip' - name: Bits diff --git a/codecov.yml b/codecov.yml index 8f36b6c..04c5585 100644 --- a/codecov.yml +++ b/codecov.yml @@ -6,7 +6,9 @@ coverage: default: target: auto threshold: 1% + informational: true patch: default: target: auto threshold: 1% + informational: true diff --git a/man/autoplot.explain.Rd b/man/autoplot.explain.Rd index 3cb1166..ebee7a7 100644 --- a/man/autoplot.explain.Rd +++ b/man/autoplot.explain.Rd @@ -10,6 +10,7 @@ feature = NULL, num_features = NULL, X = NULL, + feature_values = NULL, color_by = NULL, smooth = FALSE, smooth_color = "red", @@ -39,6 +40,11 @@ Default is \code{NULL} which will cause all variables to be displayed.} \item{X}{A matrix-like R object (e.g., a data frame or matrix) containing ONLY the feature columns from the training data.} +\item{feature_values}{A matrix-like R object (e.g., a data frame or matrix) +containing the feature values correposnding to the instance being explained. +Only used when \code{type = "dependence"}. \strong{NOTE:} Must contain the +same column structure (e.g., column names, order, etc.) as \code{X}.} + \item{color_by}{Character string specifying an optional feature column in \code{X} to use for coloring whenever \code{type = "dependence"}.} diff --git a/man/fastshap-package.Rd b/man/fastshap-package.Rd index 8e68554..7cb5632 100644 --- a/man/fastshap-package.Rd +++ b/man/fastshap-package.Rd @@ -6,8 +6,6 @@ \alias{fastshap-package} \title{fastshap: Fast Approximate Shapley Values} \description{ -\if{html}{\figure{logo.png}{options: align='right' alt='logo' width='120'}} - Computes fast (relative to other implementations) approximate Shapley values for any supervised learning model. Shapley values help to explain the predictions from any black box model using ideas from game diff --git a/man/figures/logo-fastshap.png b/man/figures/logo-fastshap.png new file mode 100644 index 0000000..d3265c7 Binary files /dev/null and b/man/figures/logo-fastshap.png differ diff --git a/man/figures/logo-fastshap.svg b/man/figures/logo-fastshap.svg new file mode 100644 index 0000000..d59ca3d --- /dev/null +++ b/man/figures/logo-fastshap.svg @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/man/figures/logo.png b/man/figures/logo.png deleted file mode 100644 index 72b0259..0000000 Binary files a/man/figures/logo.png and /dev/null differ diff --git a/slowtests/fastshap-ames.R b/slowtests/fastshap-ames.R index 9fd38f3..522edc7 100644 --- a/slowtests/fastshap-ames.R +++ b/slowtests/fastshap-ames.R @@ -1,9 +1,8 @@ # Load required packages library(doParallel) # library(fastshap) +library(ggplot2) library(pdp) -library(ranger) -library(vip) # Load the Ames housing data ames <- as.data.frame(AmesHousing::make_ames()) @@ -11,7 +10,7 @@ X <- subset(ames, select = -Sale_Price) # feature columns only # Fit a random forest model set.seed(101) # for reproducibility -rfo <- ranger(Sale_Price ~ ., data = ames, importance = "permutation") +rfo <- ranger::ranger(Sale_Price ~ ., data = ames, importance = "permutation") # Prediction wrapper pfun <- function(object, newdata) { @@ -24,9 +23,9 @@ time1 <- system.time( shap1 <- fastshap::explain(rfo, X = X, pred_wrapper = pfun, nsim = 10, .progress = "text") ) -# > time1 +# > time1 # version 0.0.5 # user system elapsed -# 1001.506 17.423 373.066 +# 1069.390 14.840 418.975 # # Version 0.0.3 reported 347.988 seconds @@ -41,21 +40,6 @@ time2 <- system.time( # user system elapsed # 1267.633 14.429 173.389 -library(ggplot2) - -shap3 <- reshape2::melt(shap2, measure.vars = names(shap2), - variable.name = "Variable", value.name = "SHAP") - - -shap_vi <- data.frame( - Variable = names(shap2), - Importance = apply(shap2, MARGIN = 2, FUN = function(x) mean(abs(x))) -) - -shap4 <- merge(shap3, shap_vi, by = "Variable") - -ggplot(shap4, aes(x = SHAP, y = reorder(Variable, Importance))) + - ggbeeswarm::geom_quasirandom(groupOnX = FALSE, varwidth = TRUE, - size = 0.4, alpha = 0.25) + - xlab("SHAP value") + - ylab(NULL) +# Shapley-based dependence plot +autoplot(shap2, type = "dependence", feature = "Gr_Liv_Area", + X = X, alpha = 0.3) + geom_smooth() diff --git a/tools/logo-fastshap.R b/tools/logo-fastshap.R index 4343b42..b6783bf 100644 --- a/tools/logo-fastshap.R +++ b/tools/logo-fastshap.R @@ -11,19 +11,15 @@ hex <- data.frame(x = 1.35 * 1 * c(-sqrt(3) / 2, 0, rep(sqrt(3) / 2, 2), 0, rep(-sqrt(3) / 2, 2)), y = 1.35 * 1 * c(0.5, 1, 0.5, -0.5, -1, -0.5, 0.5)) -# Color palettes -reds <- RColorBrewer::brewer.pal(9, "Reds") -greys <- RColorBrewer::brewer.pal(9, "Greys") - # Hexagon logo hex_logo <- ggplot() + geom_polygon(data = hex, aes(x, y), color = "#351D7D", fill = "white", - size = 2) + + size = 3) + annotation_custom(img, xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf) + annotate(geom = "text", label = "fastshap", x = -0.4, y = -0.15, - # family = "Times", - fontface = "bold.italic", - color = "#86AEC8", size = 4.5) + + family = "Comic Sans MS", + # fontface = "bold.italic", + color = "#86AEC8", size = 7) + coord_equal(xlim = range(hex$x), ylim = range(hex$y)) + scale_x_continuous(expand = c(0.04, 0)) + scale_y_reverse(expand = c(0.04, 0)) + @@ -41,18 +37,12 @@ hex_logo <- ggplot() + panel.grid.minor = element_blank()) print(hex_logo) -# Function to save sticker -save_sticker <- function(filename, sticker = last_plot(), ...) { - ggplot2::ggsave( - sticker, - width = 43.9, - height = 50.8, - filename = filename, - bg = "transparent", - units = "mm", - ... - ) -} +png("man/figures/logo-fastshap.png", width = 181, height = 209, + bg = "transparent", type = "quartz") +print(hex_logo) +dev.off() -# Save sticker -save_sticker("man/figures/logo.png", sticker = hex_logo) +svg("man/figures/logo-fastshap.svg", width = 181 / 72, height = 209 / 72, + bg = "transparent", family = "Comic Sans MS") +print(hex_logo) +dev.off()