Example code using PR Curve TensorBoard plugin with Keras
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Ignore directories Dec 3, 2017
LICENSE Initial commit Dec 3, 2017
Pipfile Use pipenv and update README Nov 6, 2018
Pipfile.lock Use pipenv and update README Nov 6, 2018
README.md Use pipenv and update README Nov 6, 2018
example.py s/tag/name Nov 6, 2018
example_screenshot.png Use pipenv and update README Nov 6, 2018


Precision-Recall curve with Keras

A blog post describing the work here can be found on my Medium profile.

TensorBoard is a suite of visualizations for inspecting and understanding your TensorFlow models and runs. They recently released of a "consistent set of APIs that allows developers to add custom visualization plugins to TensorBoard". There are already several plugins available.

Keras "is a high-level neural networks API, written in Python and capable of running on top of TensorFlow, CNTK, or Theano". When using the TensorFlow backend, they typically support the TensorBoard callback, to take advantage for its visualizations.

Keras' TensorBoard callback, however, still do not support the plugins. I recently wanted to use the Precision-Recall curve plugin (pr_curve) to see how my binary classification problem was doing. I ended up writing an extension of the callback supporting it. Although it is only a partial support (lacks usage of weights, for example), hopefully this will help anyone else in need of similar code, since I've found very little material about it around the web.

Run the Example:

Make sure you have pipenv installed, so we can have the right dependencies to reproduce this. Having installed it, run:

pipenv shell
python3 example.py
tensorboard --logdir=./logs

The script will download a small dataset to run the example on real data. The data is from UC Irvine Machine Learning Repository, specifically the Breast Cancer Wisconsin (Diagnostic) Data Set.

Follows a screenshot we the result:

Example screen shot