{"id":13704355,"url":"https://github.com/mayer79/flashlight","last_synced_at":"2025-08-21T10:32:10.408Z","repository":{"id":35933987,"uuid":"198092534","full_name":"mayer79/flashlight","owner":"mayer79","description":"Machine learning explanations","archived":false,"fork":false,"pushed_at":"2024-07-24T16:49:06.000Z","size":65826,"stargazers_count":22,"open_issues_count":2,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-26T09:25:13.551Z","etag":null,"topics":["interpretability","interpretable-machine-learning","machine-learning","r","r-package","xai"],"latest_commit_sha":null,"homepage":"https://mayer79.github.io/flashlight/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mayer79.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-21T18:41:17.000Z","updated_at":"2024-10-20T17:13:10.000Z","dependencies_parsed_at":"2023-02-18T19:16:00.473Z","dependency_job_id":"623ae143-fa8c-40ba-bff8-c88d1ac89046","html_url":"https://github.com/mayer79/flashlight","commit_stats":{"total_commits":207,"total_committers":2,"mean_commits":103.5,"dds":0.004830917874396157,"last_synced_commit":"8bcaf5c4039b454b1fe4ec55e82abb0d0bc44ee5"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayer79%2Fflashlight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayer79%2Fflashlight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayer79%2Fflashlight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayer79%2Fflashlight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mayer79","download_url":"https://codeload.github.com/mayer79/flashlight/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230507051,"owners_count":18236944,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["interpretability","interpretable-machine-learning","machine-learning","r","r-package","xai"],"created_at":"2024-08-02T21:01:08.044Z","updated_at":"2025-08-21T10:32:10.382Z","avatar_url":"https://github.com/mayer79.png","language":"R","readme":"# {flashlight} \u003ca href='https://github.com/mayer79/flashlight'\u003e\u003cimg src='man/figures/logo.png' align=\"right\" height=\"139\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n\n[![R-CMD-check](https://github.com/mayer79/flashlight/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/mayer79/flashlight/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/mayer79/flashlight/graph/badge.svg)](https://app.codecov.io/gh/mayer79/flashlight)\n[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/flashlight)](https://cran.r-project.org/package=flashlight)\n\n[![](https://cranlogs.r-pkg.org/badges/flashlight)](https://cran.r-project.org/package=flashlight) \n[![](https://cranlogs.r-pkg.org/badges/grand-total/flashlight?color=orange)](https://cran.r-project.org/package=flashlight)\n\n\u003c!-- badges: end --\u003e\n\n## Overview\n\nThe goal of this package is shed light on black box machine learning models.\n\nThe main props of {flashlight}:\n\n1. It is simple, yet flexible.\n2. It offers model agnostic tools like model performance, variable importance, global surrogate models, ICE profiles, partial dependence, ALE, and further effects plots, scatter plots, interaction strength, and variable contribution breakdown/SHAP for single observations.\n3. It allows to assess multiple models side-by-side.\n4. It supports \"group by\" operations.\n5. It works with case weights.\n\nCurrently, models with numeric or binary response are supported.\n\n## Installation\n\n```r\n# From CRAN\ninstall.packages(\"flashlight\")\n\n# Development version\ndevtools::install_github(\"mayer79/flashlight\")\n```\n\n## Usage\n\nLet's start with an iris example. For simplicity, we do not split the data into training and testing/validation sets.\n\n```r\nlibrary(ggplot2)\nlibrary(MetricsWeighted)\nlibrary(flashlight)\n\nfit_lm \u003c- lm(Sepal.Length ~ ., data = iris)\n\n# Make explainer object\nfl_lm \u003c- flashlight(\n  model = fit_lm, \n  data = iris, \n  y = \"Sepal.Length\", \n  label = \"lm\",               \n  metrics = list(RMSE = rmse, `R-squared` = r_squared)\n)\n```\n\n### Performance\n\n```r\nfl_lm |\u003e \n  light_performance() |\u003e \n  plot(fill = \"darkred\") +\n  labs(x = element_blank(), title = \"Performance on training data\")\n\nfl_lm |\u003e \n  light_performance(by = \"Species\") |\u003e \n  plot(fill = \"darkred\") +\n  ggtitle(\"Performance split by Species\")\n```\n\n\u003cp\u003e\n  \u003cimg src=\"man/figures/perf.svg\" alt=\"Performance\" width=\"40%\" hspace=\"20\"/\u003e\n  \u003cimg src=\"man/figures/perf_grouped.svg\" alt=\"Grouped\" width=\"40%\" hspace=\"20\"/\u003e\n\u003c/p\u003e\n\n\n### Permutation importance regarding first metric\n\nError bars represent standard errors, i.e., the uncertainty of the estimated importance.\n\n```r\nfl_lm |\u003e\n  light_importance(m_repetitions = 4) |\u003e \n  plot(fill = \"darkred\") +\n  labs(title = \"Permutation importance\", y = \"Increase in RMSE\")\n```\n\n![](man/figures/imp.svg)\n\n### ICE curves for `Petal.Width`\n\n```r\nfl_lm |\u003e \n  light_ice(\"Sepal.Width\", n_max = 200) |\u003e \n  plot(alpha = 0.3, color = \"chartreuse4\") +\n  labs(title = \"ICE curves for 'Sepal.Width'\", y = \"Prediction\")\n\nfl_lm |\u003e \n  light_ice(\"Sepal.Width\", n_max = 200, center = \"middle\") |\u003e \n  plot(alpha = 0.3, color = \"chartreuse4\") +\n  labs(title = \"c-ICE curves for 'Sepal.Width'\", y = \"Prediction (centered)\")\n```\n\n\u003cp\u003e\n  \u003cimg src=\"man/figures/ice.svg\" alt=\"Performance\" width=\"40%\" hspace=\"20\"/\u003e\n  \u003cimg src=\"man/figures/cice.svg\" alt=\"Grouped\" width=\"40%\" hspace=\"20\"/\u003e\n\u003c/p\u003e\n\n### PDPs\n\n```r\nfl_lm |\u003e \n  light_profile(\"Sepal.Width\", n_bins = 40) |\u003e \n  plot() +\n  ggtitle(\"PDP for 'Sepal.Width'\")\n\nfl_lm |\u003e \n  light_profile(\"Sepal.Width\", n_bins = 40, by = \"Species\") |\u003e \n  plot() +\n  ggtitle(\"Same grouped by 'Species'\")\n```\n\n\u003cp\u003e\n  \u003cimg src=\"man/figures/pdp.svg\" alt=\"Performance\" width=\"40%\" hspace=\"20\"/\u003e\n  \u003cimg src=\"man/figures/pdp_grouped.svg\" alt=\"Grouped\" width=\"40%\" hspace=\"20\"/\u003e\n\u003c/p\u003e\n\n### 2D PDP\n\n```r\nfl_lm |\u003e \n  light_profile2d(c(\"Petal.Width\", \"Petal.Length\")) |\u003e \n  plot()\n```\n\n![](man/figures/pdp2d.svg)\n\n### ALE\n\n```r\nfl_lm |\u003e \n  light_profile(\"Sepal.Width\", type = \"ale\") |\u003e \n  plot() +\n  ggtitle(\"ALE plot for 'Sepal.Width'\")\n```\n\n![](man/figures/ale.svg)\n\n### Different profile plots in one\n\n```r\nfl_lm |\u003e \n  light_effects(\"Sepal.Width\") |\u003e \n  plot(use = \"all\") +\n  ggtitle(\"Different types of profiles for 'Sepal.Width'\")\n```\n\n![](man/figures/effects.svg)\n\n### Variable contribution breakdown for single observation\n\n```r\nfl_lm |\u003e \n  light_breakdown(new_obs = iris[1, ]) |\u003e \n  plot()\n```\n\n![](man/figures/breakdown.svg)\n\n### Global surrogate tree\n\n```r\nfl_lm |\u003e \n  light_global_surrogate() |\u003e \n  plot()\n```\n\n![](man/figures/surrogate.svg)\n\n### Multiple models\n\nMultiple flashlights can be combined to a multiflashlight.\n\n```r\nlibrary(rpart)\n\nfit_tree \u003c- rpart(\n  Sepal.Length ~ ., \n  data = iris, \n  control = list(cp = 0, xval = 0, maxdepth = 5)\n)\n\n# Make explainer object\nfl_tree \u003c- flashlight(\n  model = fit_tree, \n  data = iris, \n  y = \"Sepal.Length\", \n  label = \"tree\",               \n  metrics = list(RMSE = rmse, `R-squared` = r_squared)\n)\n\n# Combine with other explainer\nfls \u003c- multiflashlight(list(fl_tree, fl_lm))\n\nfls |\u003e \n  light_performance() |\u003e \n  plot(fill = \"chartreuse4\") +\n  labs(x = \"Model\", title = \"Performance\")\n\nfls |\u003e \n  light_profile(\"Petal.Length\", n_bins = 40, by = \"Species\") |\u003e \n  plot() +\n  ggtitle(\"PDP by Species\")\n```\n\n\u003cp\u003e\n  \u003cimg src=\"man/figures/perf_grouped_multi.svg\" alt=\"Performance\" width=\"40%\" hspace=\"20\"/\u003e\n  \u003cimg src=\"man/figures/pdp_grouped_multi.svg\" alt=\"Grouped\" width=\"40%\" hspace=\"20\"/\u003e\n\u003c/p\u003e\n\n## More\n\nCheck out the vignette for more information and important references.\n","funding_links":[],"categories":["Tools","Technical Resources"],"sub_categories":["Interpretability/Explicability","Open Source/Access Responsible AI Software Packages"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayer79%2Fflashlight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmayer79%2Fflashlight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayer79%2Fflashlight/lists"}