A step-by-step manual for installing NILMTK

3 minute read

Published:

In this manual, we will explain how to install the user version of NILMTK step by step. Please note that this manual considers Mac OS and Linux systems only. The installation procedure for Windows might differ from the one presented in this blog post.

Our manual builds on the splendid NILMTK manual:

We want to thank the NILMTK developer team for their efforts!

A Prerequisite: Conda

Virtual environments make it super easy to organise your Python packages. We suggest Conda for this purpose. Why? Well:

With over 6 million users, the open source Anaconda Distribution is the easiest way to do Python data science and machine learning. It includes hundreds of popular data science packages and the conda package and virtual environment manager for Windows, Linux, and MacOS. Conda makes it quick and easy to install, run, and upgrade complex data science and machine learning environments like Scikit-learn, TensorFlow, and SciPy. Anaconda Distribution is the foundation of millions of data science projects as well as Amazon Web Services’ Machine Learning AMIs and Anaconda for Microsoft on Azure and Windows.

Get Anaconda for Python 3.6 here.

Open a terminal window and start the installation from command line:

cd Downloads/
sudo bash Anaconda3-5.2.0-Linux-x86_64.sh -u

This will initiate the installation process, which will guide you through several steps. Install Conda and test the installation by executing the command conda in the command prompt.

In case of Error: No such file or directory

In case the command conda results in a bad interpreter error, apply the following fix:

cd /home/user/
nano .bashrc

add the line: export PATH=~/anaconda3/bin:$PATH

Finally, execute the command:

source .bashrc

Before you proceed, check if you have GIT on your machine. If it’s missing, install it:

sudo apt-get install git

Installing NILMTK

Open a terminal window and navigate to your home folder.

Download environment recipe and random testset

The NILMTK developers provide a Conda ‘recipe’ for NILMTK. We host it on our site. For post-installation tests, you should download a random test set in the same vein.

wget https://klemenjak.github.io/files/environment.yml
wget https://raw.githubusercontent.com/nilmtk/nilmtk/master/data/random.h5

NILMTK environment

Now that you have the recipe, you can create a NILMTK environment.

conda env create -f=environment.yml

Alternatively, open Anaconda Navigator and use the graphical user interface:

Jupyter

Basically, the heartpiece of NILMTK is now installed on your computer. The next step involves Jupyter notebooks. Working with Jupyter opens up many posibilities and is said to be a must-have feature. Therefore, add the environment to Jupyter:

Now, most of our desired packages are installed and the NILMTK env is ready to roll! To activate it, execute:

source activate nilmtk-env
python -m ipykernel install --user --name nilmtk-env --display-name "Python (nilmtk)"

Testing your Installation

The time has come to check your installation. Create a new folder and open Jupyter.

mkdir tk
jupyter notebook tk/

Create a new notebook, don’t forget to use “Python (nilmtk)”, and fill in these two fields:

IN[1]:

from nilmtk import DataSet
%matplotlib inline

ds = DataSet('/Users/christoph/random.h5')
elec = ds.buildings[1].elec
elec

IN[2]:

elec[1].plot()

Here is what you should see now:

Optional: Configure PyCharm IDE

In development environments such as PyCharm, you should be able to integrate nilmtk-env now.

Optional: Add TensorFlow and Keras to your Conda installation

Deep Learning is a hot topic and also in NILM, many researchers are using Deep Learning Frameworks. That’s why it might be a good idea to integrate TensorFlow into your NILMTK environment from the start.

To install the CPU version of TF and Keras, run:

pip install tensorflow keras

For GPU support:

pip install tensorflow-gpu keras

That’s it. Thanks for stopping by! You are set up and ready to rock!

Comments and remarks are highly appreciated.

  1. Christoph Klemenjak and Peter Goldsborough, Non-intrusive load monitoring: A review and outlook, arXiv preprint arXiv:1610.01191, 2016.

Comments