Coder Social home page Coder Social logo

waterfall's Introduction

waterfallcharts

Description

Waterfall charts are great at visualizing marginal value contributions to some system or starting value (bias). This package is a hassle free way to generate them in Python!

The idea was first brought to my attention by Jeremy Howard, who remarked that no such package existed. The underlying method borrows from Chris Moffitt's stacked bar charts approach, and improves upon data range reliability, appearance, and chart options.

The application use of waterfall charts is up to the user's creativity! These charts are great at visualizing revenue and expenses, but are universally applicable to showing any kind of marginal contributions to a system.

Thank you to Jade Yun for the random forest decision tree interpreter example, and for the sorted_values and thresholding features.

Usage

As detailed in the example and source code, the function assumes two list inputs, one of the contribution names and the other of the contribution amounts. Please note that the net sum of all contributions is not an input to the function, and is calculated for you.

import waterfall_chart

a = ['sales','returns','credit fees','rebates','late charges','shipping']
b = [10,-30,-7.5,-25,95,-7]

my_plot = waterfall_chart.plot(a, b)

Functionality

There is currently one function:

  • plot(): Given two sequences ordered appropriately, of contribution amounts and labels, generate a standard waterfall chart


There are three features:

  • sorted_value: Sorts contributions by absolute value in the chart

  • threshold: Groups all contributions under a certain threshold value into an 'other' group

  • formatting: Formats Y axis labels and bar chart labels to the specified input

Additionally, there are several arguments that control for chart title, axis names, bar colors, custom bar labels for 'other' and 'net', and x label rotation angles


Check out these examples for simple charts.

Random forest interpretation

Additionally, the output metrics of a decision tree interpreter can be provided to a waterfall chart. This allows for a visualization of incremental contributions of the tree's nodes to the final prediction - a nice way to see what your random forest is doing. For example, after constructing a random forest on sklearn's breast cancer dataset, we obtain the breakdown of feature contributions to the final prediction for one row of the data. We can use a waterfall chart to intuitively relay this information to an audience. For example, the patient's diagnosis of whether they have breast cancer or not can be visually represented as:


Check out this example for the entire random forest code, built with the fastai library.

Installation

Simply install the Python waterfallcharts package:

$ pip install waterfallcharts

or upgrade to the latest version:

$ pip install -U waterfallcharts

Implementation notes

Deploy

$ python setup.py sdist upload

waterfall's People

Contributors

chrispaulca avatar kishmanani avatar parrt avatar

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.