Skip to content

Commit

Permalink
More pkgdown (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinju authored Jan 22, 2025
1 parent b21462f commit c30ecf3
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 29 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ jobs:
extra-packages: any::pkgdown, local::.
needs: website

- name: Render python README to assets folder
- name: Copy shaprpy readme to folder for automatic deployment
run: |
rmarkdown::render(input = "python/README.md",
output_format = "html_document",
output_file = "../pkgdown/assets/README_py.html")
file.copy("python/README.md", ".github/shaprpy.md")
shell: Rscript {0}

- name: Build site
Expand Down
14 changes: 8 additions & 6 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ knitr::opts_chunk$set(
)
```

# shapr <img src="man/figures/NR-logo_utvidet_r32g60b136_small.png" align="right" height="50px"/>
# shapr <img src="man/figures/nrlogo_new.jpg" align="right" height="139"/>

<!-- badges: start -->
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version-last-release/shapr)](https://cran.r-project.org/package=shapr)
[![CRAN_Downloads_Badge](https://cranlogs.r-pkg.org/badges/grand-total/shapr)](https://cran.r-project.org/package=shapr)
[![R build status](https://github.com/NorskRegnesentral/shapr/workflows/R-CMD-check/badge.svg)](https://github.com/NorskRegnesentral/shapr/actions?query=workflow%3AR-CMD-check)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/license/mit)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.02027/status.svg)](https://doi.org/10.21105/joss.02027)

Expand All @@ -48,7 +48,7 @@ and regression-based methods
See the [NEWS](https://github.com/NorskRegnesentral/shapr/blob/master/NEWS.md) for a complete list.

### Coming from shapr < 1.0.0?
`shapr` version > 1.0.0 comes with a number of breaking changes.
`shapr` version >= 1.0.0 comes with a number of breaking changes.
Most notably, we moved from using two function (`shapr()` and `explain()`) to
a single function (`explain()`).
In addition, custom models are now explained by passing the prediction function directly to `explain()`,
Expand All @@ -62,7 +62,7 @@ README with old syntax (v0.2.2).
We provide an (experimental) Python wrapper (`shaprpy`) which allows explaining Python models with the methodology
implemented in `shapr`, directly from Python.
The wrapper calls `R` internally, and therefore requires an installation of `R`.
See [here](https://github.com/NorskRegnesentral/shapr/tree/master/python) for installation instructions and examples.
See [here](https://github.com/NorskRegnesentral/shapr/shaprpy.html) for installation instructions and examples.


## The package
Expand Down Expand Up @@ -175,8 +175,10 @@ plot(explanation)
```

See the [general usage vignette](https://norskregnesentral.github.io/shapr/articles/general_usage.html) for further
basic usage examples.

basic usage examples and brief introductions to the methodology.
For more thorough information about the underlying methodology, see
@aas2019explaining, @redelmeier2020explaining, @jullum2021efficient, @olsen2022using, @olsen2024comparative .
See also @sellereite2019shapr for a brief paper about the previous (< 1.0.0) version of the package.

## Contribution

Expand Down
80 changes: 70 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

# shapr <img src="man/figures/NR-logo_utvidet_r32g60b136_small.png" align="right" height="50px"/>
# shapr <img src="man/figures/nrlogo_new.jpg" align="right" height="139"/>

<!-- badges: start -->

Expand All @@ -10,16 +10,15 @@
[![R build
status](https://github.com/NorskRegnesentral/shapr/workflows/R-CMD-check/badge.svg)](https://github.com/NorskRegnesentral/shapr/actions?query=workflow%3AR-CMD-check)
[![Lifecycle:
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)
stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![License:
MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/license/mit)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.02027/status.svg)](https://doi.org/10.21105/joss.02027)

See the pkgdown site at
[norskregnesentral.github.io/shapr/](https://norskregnesentral.github.io/shapr/)
for a complete introduction with examples and documentation of the
package.
<!-- badges: end -->
package. <!-- badges: end -->

## NEWS

Expand All @@ -46,7 +45,7 @@ for a complete list.

### Coming from shapr \< 1.0.0?

`shapr` version \> 1.0.0 comes with a number of breaking changes. Most
`shapr` version \>= 1.0.0 comes with a number of breaking changes. Most
notably, we moved from using two function (`shapr()` and `explain()`) to
a single function (`explain()`). In addition, custom models are now
explained by passing the prediction function directly to `explain()`,
Expand All @@ -63,8 +62,8 @@ We provide an (experimental) Python wrapper (`shaprpy`) which allows
explaining Python models with the methodology implemented in `shapr`,
directly from Python. The wrapper calls `R` internally, and therefore
requires an installation of `R`. See
[here](https://github.com/NorskRegnesentral/shapr/tree/master/python)
for installation instructions and examples.
[here](https://github.com/NorskRegnesentral/shapr/shaprpy.html) for
installation instructions and examples.

## The package

Expand Down Expand Up @@ -183,14 +182,14 @@ explanation <- explain(
#> max_n_coalitions is NULL or larger than or 2^n_features = 16,
#> and is therefore set to 2^n_features = 16.
#>
#> ── Starting `shapr::explain()` at 2025-01-21 13:30:06 ──────────────────────────
#> ── Starting `shapr::explain()` at 2025-01-22 10:22:36 ──────────────────────────
#> • Model class: <xgb.Booster>
#> • Approach: empirical
#> • Iterative estimation: FALSE
#> • Number of feature-wise Shapley values: 4
#> • Number of observations to explain: 6
#> • Computations (temporary) saved at:
#> '/tmp/Rtmpf5zleu/shapr_obj_3676de5b39f33b.rds'
#> '/tmp/RtmpAnmtGl/shapr_obj_371a1a52bf4cce.rds'
#>
#> ── Main computation started ──
#>
Expand All @@ -216,7 +215,12 @@ plot(explanation)

See the [general usage
vignette](https://norskregnesentral.github.io/shapr/articles/general_usage.html)
for further basic usage examples.
for further basic usage examples and brief introductions to the
methodology. For more thorough information about the underlying
methodology, see Aas, Jullum, and Løland (2021), Redelmeier, Jullum, and
Aas (2020), Jullum, Redelmeier, and Aas (2021), Olsen et al. (2022),
Olsen et al. (2024) . See also Sellereite and Jullum (2019) for a brief
paper about the previous (\< 1.0.0) version of the package.

## Contribution

Expand All @@ -232,3 +236,59 @@ Conduct](https://norskregnesentral.github.io/shapr/CODE_OF_CONDUCT.html).
By contributing to this project, you agree to abide by its terms.

## References

<div id="refs" class="references csl-bib-body hanging-indent">

<div id="ref-aas2019explaining" class="csl-entry">

Aas, Kjersti, Martin Jullum, and Anders Løland. 2021. “Explaining
Individual Predictions When Features Are Dependent: More Accurate
Approximations to Shapley Values.” *Artificial Intelligence* 298.

</div>

<div id="ref-jullum2021efficient" class="csl-entry">

Jullum, Martin, Annabelle Redelmeier, and Kjersti Aas. 2021. “Efficient
and Simple Prediction Explanations with groupShapley: A Practical
Perspective.” In *Proceedings of the 2nd Italian Workshop on Explainable
Artificial Intelligence*, 28–43. CEUR Workshop Proceedings.

</div>

<div id="ref-olsen2022using" class="csl-entry">

Olsen, Lars Henry Berge, Ingrid Kristine Glad, Martin Jullum, and
Kjersti Aas. 2022. “Using Shapley Values and Variational Autoencoders to
Explain Predictive Models with Dependent Mixed Features.” *Journal of
Machine Learning Research* 23 (213): 1–51.

</div>

<div id="ref-olsen2024comparative" class="csl-entry">

———. 2024. “A Comparative Study of Methods for Estimating Model-Agnostic
Shapley Value Explanations.” *Data Mining and Knowledge Discovery*,
1–48.

</div>

<div id="ref-redelmeier2020explaining" class="csl-entry">

Redelmeier, Annabelle, Martin Jullum, and Kjersti Aas. 2020. “Explaining
Predictive Models with Mixed Features Using Shapley Values and
Conditional Inference Trees.” In *International Cross-Domain Conference
for Machine Learning and Knowledge Extraction*, 117–37. Springer.

</div>

<div id="ref-sellereite2019shapr" class="csl-entry">

Sellereite, N., and M. Jullum. 2019. “Shapr: An r-Package for Explaining
Machine Learning Models with Dependence-Aware Shapley Values.” *Journal
of Open Source Software* 5 (46): 2027.
<https://doi.org/10.21105/joss.02027>.

</div>

</div>
2 changes: 1 addition & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ navbar:
href: reference/index.html
python:
text: Python
href: README_py.html
href: shaprpy.html
12 changes: 12 additions & 0 deletions inst/REFERENCES.bib
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,15 @@ @inproceedings{covert2021improving
organization={PMLR}
}


@article{sellereite2019shapr,
title = {shapr: An R-package for explaining machine learning models with dependence-aware Shapley values},
author = {Sellereite, N. and Jullum, M.},
journal = {Journal of Open Source Software},
year = {2019},
volume = {5},
number = {46},
pages = {2027},
doi = {10.21105/joss.02027}
}

Binary file added man/figures/nrlogo_new.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 4 additions & 8 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
---
output:
html_document: default
pdf_document: default
---
## shaprpy

# shaprpy

Python wrapper for the R package [shapr](https://github.com/NorskRegnesentral/shapr).

NOTE: This wrapper is in an EXPERIMENTAL state. Bugs and breaking changes are not unlikely to occur.
NOTE: This wrapper is in an EXPERIMENTAL state. Bugs are not unlikely to occur.

### Install

The below instructions assume you already have `pip` and `R` installed and exposed to the python environment where you want to run `shaprpy`.
Official instructions for installing `pip` can be found [here](https://pip.pypa.io/en/stable/installation/), and for `R` [here](https://cran.r-project.org/).
R can also be installed with pip as follows:
`R` can also be installed with pip as follows:
```
pip install rbase
```
Expand Down

0 comments on commit c30ecf3

Please sign in to comment.