Giter VIP home page Giter VIP logo

rme's Introduction

RME

Build Status codecov

Overview

Recurrent Memory Explainer (RME) is a tool for creating interpretable explanations, dedicated to models operating on sequential data. RME focuses on the memory of a sequential model and tries to explain the decision by pointing important places in the sequence that had an effect on the prediction. RME is based on so-called „memory profiles”, which are intuitive and can be easily visualised on simple plot charts.

Installation

RME can be istalled directly from github using pip:

pip install git+https://github.com/ModelOriented/RME

Demo

A machine learning model predicting the sentiment of the sentence (whether it is positive or negative) serves as an example of RME demo explanations. Full code of an example can be found in notebooks folder.

1. Creating an explainer

At the beginning, we create an explainer and pass the whole dataset to construct a vocabulary. The vocabulary is going to be used to construct perturbations of the instance being explained.

from RME import explainer.Explainer

e = Explainer(train_set=data)

2. Explaining instance

We are interested in explaining the following instance: It is a wonderful World!. We need to pass model's predict_proba function, which outputs classes' probabilities and supply the class we are interested (0 - negative / 1 - positive).

e.explain_instance(instance = ['What a wonderful World!'], predict_function = predict_function, class_index=1)

We can also calculate step-by-step prediction to see how the prediction changed after each word.

e.explain_instance(instance = ['What a wonderful World!'], predict_function = predict_function, class_index=1)

3. Visualization

After explaining the instance, the module is ready to visualize obtained results.

e.plot_local_perturbations(type='probability_change', title = 'Demo explanation, class: positive')

e.plot_local_perturbations(type='probability_change', title = 'Demo explanation, class: positive')

e.plot_local_perturbations(type='probability_change', title = 'Demo explanation, class: positive')

Once the explainer is constructed, it can serve for various instances. Below, the RME visualizes the impact of the following words on negative sentiment prediction for the sentence: It was the worst and most boring movie I have ever seen.

e.explain_instance(instance=['It was the worst movie I have ever seen!'],predict_function=predict_function,class_index=0)
e.plot_local_perturbations(type='probability_change', title = 'Demo explanation, class: positive')

Documentation

For all the features the package offers, see the documentation.

The package was created as a part of master's diploma thesis at Warsaw University of Technology at Faculty of Mathematics and Information Science by Mateusz Kobyłka.

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.