Jupyter + Rails

Jupyter notebooks are a great alternative to the Rails console for doing exploratory data analysis and building predictive models. Here’s how to get setup:

First, install Jupyter. With Homebrew, use:

brew install jupyterlab

Add to your Gemfile

group :development do
  gem 'iruby', require: false
  gem 'ffi-rzmq', require: false


bundle install
bundle exec iruby register --force

Start Jupyter

jupyter notebook

Create a notebook and add to the top

require "./config/environment"

If not at Rails root, use Dir.chdir("path/to/root") { require "./config/environment" }

And science away


If you use Git, add to .gitignore


If you use Nyaplot, use the master branch to fix an issue with empty charts.

gem 'nyaplot', github: 'domitry/nyaplot'

Published June 19, 2018

You might also enjoy

XGBoost and LightGBM Come to Ruby

Emotion Recognition in Ruby

Introducing pdscan: Scan Your Data Stores for Unencrypted Personal Data

All code examples are public domain.
Use them however you’d like (licensed under CC0).