HTM Engine example application: live NYC traffic anomaly detection.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
images Updating architecture image. Aug 3, 2015
.gitignore Fixed some data bugs. Jul 6, 2015
LICENSE.txt Add GPLv3.0 license. Jun 15, 2015 Added warning about River View Mar 9, 2017

This source code is accompanied by a tutorial screencast.

YouTube Screenshot of HTM Engine Tutorial

WARNING: This project is currently broken because of an issue with the River View data service.

This application has two or more parts.

1. HTM Engine Python Server

This server runs NuPIC within the HTM Engine. You must follow those installation instructions before this will work. Then you should start the server with supervisord (see the README).

2. Node.js Client Application

This fetches the data, controls the HTM Engine via HTTP, pipes in mountains of data, displays results in webapp.

3. River View Traffic Data Service

This application is using a data service called River View, which is currently running at It provides temporal data within a 6-month window, which includes NYC traffic data.

HTM Engine Traffic Demo Architecture


This project started with a fork of the skeleton-htmengine-app. That project is a great place to start if you want to create your own HTM Engine instance. All you really need to change is the MySQL database name and RabbitMQ queue names.


Also, if you want to view the map of all the traffic paths (at http://localhost:8083/map) you'll need a Google Maps API key.

export GOOGLE_MAPS_API_KEY=<your key>


Install and Start HTM Engine (Python)

Read and follow python-engine/, then continue with the directions below.

Start HTM HTTP Server (Python)

This provides a simple GET/POST/PUT HTTP interface on top of the HTM Engine, which is really useful if you don't want to write your HTM application in python. HTM services must be running in supervisor for this HTTP interface to work properly.

cd python-engine

This will run at http://localhost:8080.

Install HTM Client (JavaScript)

cd node-client
npm install .

Start HTM Client (JavaScript)

npm start

This will run at http://localhost:8083.


Immediately after startup, the Node.js client application will start pulling traffic data from River View and pushing it into the HTM Engine. A model is created for every traffic route available. For example, traffic path "1" contains traffic data for "11th ave n ganservoort - 12th ave @ 40th st" in Manhattan. This correlates to an HTM Engine model named "1". You can see the raw data for this model by querying the Python HTM Engine HTTP wrapper at http://localhost:8080/1. You should see a bunch of text data in the response.


There are lots of Dygraphs and Google Maps.