Coder Social home page Coder Social logo

viadee / anchorsonr Goto Github PK

View Code? Open in Web Editor NEW
15.0 6.0 5.0 13.29 MB

Implementation of the Anchors algorithm: Explain black-box ML models

License: BSD 3-Clause "New" or "Revised" License

R 100.00%
xai machine-learning explainable-ai r anchors rules iml

anchorsonr's People

Contributors

fkoehne avatar magdalenalang1 avatar thllwg avatar tobiasgoerke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

anchorsonr's Issues

Coverage identification and performance issues

Coverage identification does not work properly, as of now.
Additionally, the perturbations needed to calculate coverage are created each time the coverage identification is called. This can happen once at initialization time.

Create a new Unsupervised-Discretizer

Since we did not find a non-GPL CRAN-hosted package, that discretizes continuous data in an unsupervised manner #44 , an unsupervised discretizer should be implemented directly.
It could resemble the implementations of viadee in the 'javaAnchorAdapters' package.
https://github.com/viadee/javaAnchorAdapters/tree/master/DefaultConfigsExtension/src/main/java/de/viadee/xai/anchor/adapter/tabular/discretizer/impl

Useful discretizers could be equalfrequency (PercentileMedianDiscretizers) and manual cutpoints (ManualDiscretizer).

and should discretize as shown in the tests:

https://github.com/viadee/javaAnchorAdapters/tree/master/DefaultConfigsExtension/src/test/java/de/viadee/xai/anchor/adapter/tabular/discretizer

shorten JVM waiting time

In R/connections.R -> initAnchors() the JVM is started. Til now, the function just falls asleep for 5 seconds to let the JVM start. Clearly not a good solution. We need to find a dynamic way to handle this.

.anchors.startJar(ip = ip, port = port, name = name, ice_root = tempdir(), stdout = stdout, bind_to_localhost = FALSE, log_dir = NA, log_level = NA, context_path = NA)

Sys.sleep(5L)

Enable multithreading

The application would greatly benefit from utilizing multiple threads. For R, this is no easy task and comes with plenty overhead. However, there are multiple options we should think about. There could be multiple threads, for example, listening to incoming calls to create multiple local explanations in parallel.

Contrary to #16, this issue is not about reducing communication overhead but actually enabling threading.

Streamlined explanations / More print options

If multiple cases are explained, there should be a possibility to streamline explanations printouts. For instance, if several 'setosa' instances are explained, the resulting anchors - if similar/identical could be unified.

Example:
====Result====
IF Petal.Length IN [1,2.63333333333333) (ADDED PRECISION: 1, ADDED COVERAGE: -0.509)
THEN PREDICT 'setosa'
WITH PRECISION 1 AND COVERAGE 0.491
====For Explained Instances 15, 18 ====
====15====
Sepal.Length = 5.8
Sepal.Width = 4
Petal.Length = 1.2
Petal.Width = 0.2
WITH LABEL = 'setosa'
====18====
Sepal.Length = 5.8
Sepal.Width = 4
Petal.Length = 1.2
Petal.Width = 0.2
WITH LABEL = 'setosa'

Another nice-to-have would be the possibility to just print the rules without the instance details, e.g. via a verbosity parameter?

Make explained prediction settable

The explained prediction is set in a_dataframe.R by
prediction = predict_model(explainer$model, instance, type = o_type)

The user needs to be able to customly set the parameter he or she would like to explained. Thus, make this a parameter.

Move discretization to own class

bin_contiuous, n_bins, quantile_bins and use_density should be moved elsewhere and produce a discretized dataset that can then be passed to anchors.

Increase parallelizable workload

It seems there is high relative communication overhead.
We should try to communicate less with the Java backend.

Idea: Increase the initSampleCount, use KL_LUCB with high batchSize. Then, enable parallelization in anchorsOnR.

Discretization options are insufficient

One can control the parameters bin_contiuous, n_bins, quantile_bins and use_density to discretize variables.
To my understanding, all variables are then discretized using the same options.

This, however, does not suffice:

  1. in most cases, variables need to be discretized differently.
  2. there need to be more options than these few.

In other words: the user needs full control over the discretization settings.

We have a few options here (non exhaustive list):

  1. submit a second dataset which contains the discretized values
  2. submit a collection of discretization functions

Which other options can you think of? Which would you prefer?

Generate multiple perturbations at once

The current perturbation generation function is in need of performance improvement.
Generating all perturbations that were asked for at once would help to reduce the total runtime.

Create a new supervised discretizer

Since we did not find a non-GPL CRAN-hosted package, that discretizes continuous data in a supervised manner #44 , a supervised discretizer should be implemented directly.
It could resemble the implementations of viadee in the 'javaAnchorAdapters' package.
https://github.com/viadee/javaAnchorAdapters/tree/master/DefaultConfigsExtension/src/main/java/de/viadee/xai/anchor/adapter/tabular/discretizer/impl

Useful discretizers could be FUSINTER (FUSINTERDiscretizer.java) see:
FUSINTER_A_Method_for_Discretization_of_Continuous.pdf

or Ameva (AmevaDiscretizer.java) see:
AMEVA 2009-Gonzalez-Abril-ESWA.pdf

or another discretizer, as supervised discretizations are currently being implemented and evaluated for the Java implementation of Anchors.

These should discretize as shown in the tests:

https://github.com/viadee/javaAnchorAdapters/tree/master/DefaultConfigsExtension/src/test/java/de/viadee/xai/anchor/adapter/tabular/discretizer/impl

Merge Adapters

Merge javaAnchorAdapter changes as preparation for jar download

Explanations without train set

Why does a train set need to be passed to anchors()?
Anchors is able to run without a data set. Just the default perturbation should require a dataset

Separation of concerns

A large share of the application's logic lies currently within a few classes such as a_dataframe.R. This should be split up as it resembles very different concepts.

CRAN release

  • Create required meta files
  • Pick a version number.
  • Run and document R CMD check.
  • Check that you’re aligned with CRAN policies.
  • Update README.md and NEWS.md.
  • Submit the package to CRAN.
  • Prepare for the next version by updating version numbers.
  • Publicise the new version.

Refactor Perturbation

The perturbation code contains many "historical" legacy burdens. Based on outdated considerations, it was designed to be as flexible as possible so that different perturbation functions can be used for tabular data, images, etc. Thus, the perturbation code is accordingly complex. Since we now assume that the perturbation functions essentially exist as they are (i.e. one perturbation function for tabular data), the code could be significantly streamlined.

Printed explanation label differs from result

E.g.:

====Explained Instance 100 ==== Sepal.Length = 5.7 Sepal.Width = 2.8 Petal.Length = 4.1 Petal.Width = 1.3 WITH LABEL Species = 'versicolor' ====Result==== IF Petal.Width IN INLC RANGE [0.867,1.6) (ADDED PRECISION: 0.910299003322259, ADDED COVERAGE: -0.391) THEN PREDICT '1' ('setosa') WITH PRECISION 0.910299003322259 AND COVERAGE 0.609

Decouple jar from project

The java jar lies currently within the project.
The file needs to be removed and the current version downloaded from the maven central repository.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.