项目作者: pbiecek

项目描述 :
Model Agnostics breakDown plots
高级语言: R
项目地址: git://github.com/pbiecek/breakDown.git
创建时间: 2017-11-18T09:37:00Z
项目社区:https://github.com/pbiecek/breakDown

开源协议:

下载


CRAN_Status_Badge
Downloads
Total Downloads
Build Status
Coverage
Status

Break Down: Model Agnostic Explainers for Individual Predictions

The breakDown package is a model agnostic tool for decomposition of predictions from black boxes.
Break Down Table shows contributions of every variable to a final prediction.
Break Down Plot presents variable contributions in a concise graphical way.
This package works for binary classifiers and general regression models.

Find lots of R examples at breakDown website: https://pbiecek.github.io/breakDown/

Interested in the methodology? Find the math behind breakDown and live at: https://arxiv.org/abs/1804.01955

Looking for the python version of Break Down? Find it here: https://github.com/bondyra/pyBreakDown

New generation of the Break-Down algorithm is implemented in the iBreakDown package
https://github.com/ModelOriented/iBreakDown
. All new features will be added to the iBreakDown.

Installation

Install from CRAN

  1. install.packages("breakDown")

Install from GitHub

  1. devtools::install_github("pbiecek/breakDown")

Cheatsheets

Cheatsheet

Example for lm model

Get data with archivist

  • broken object: archivist::aread("pbiecek/breakDown/arepo/81c5be568d4db2ec795dedcb5d7d6599")
  • the plot: archivist::aread("pbiecek/breakDown/arepo/7b40949a0fdf9c22780454581d4b556e")

The R code

  1. library(breakDown)
  2. url <- 'https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-white.csv'
  3. wine <- read.table(url, header = T, sep=";")
  4. head(wine, 3)
  5. ## fixed.acidity volatile.acidity citric.acid residual.sugar chlorides free.sulfur.dioxide total.sulfur.dioxide density pH
  6. ## 1 7.0 0.27 0.36 20.7 0.045 45 170 1.0010 3.00
  7. ## 2 6.3 0.30 0.34 1.6 0.049 14 132 0.9940 3.30
  8. ## 3 8.1 0.28 0.40 6.9 0.050 30 97 0.9951 3.26
  9. ## sulphates alcohol quality
  10. ## 1 0.45 8.8 6
  11. ## 2 0.49 9.5 6
  12. ## 3 0.44 10.1 6
  13. model <- lm(quality ~ fixed.acidity + volatile.acidity + citric.acid + residual.sugar + chlorides + free.sulfur.dioxide + total.sulfur.dioxide + density + pH + sulphates + alcohol,
  14. data = wine)
  15. new_observation <- wine[1,]
  16. br <- broken(model, new_observation)
  17. br
  18. ## contribution
  19. ## (Intercept) 5.90000
  20. ## residual.sugar = 20.7 1.20000
  21. ## density = 1.001 -1.00000
  22. ## alcohol = 8.8 -0.33000
  23. ## pH = 3 -0.13000
  24. ## free.sulfur.dioxide = 45 0.03600
  25. ## sulphates = 0.45 -0.02500
  26. ## volatile.acidity = 0.27 0.01500
  27. ## fixed.acidity = 7 0.00950
  28. ## total.sulfur.dioxide = 170 -0.00900
  29. ## citric.acid = 0.36 0.00057
  30. ## chlorides = 0.045 0.00019
  31. ## final_prognosis 5.60000
  32. plot(br)

plot for lm model