Dream to Learn is shutting down...

We are very sorry to say that Dream to Learn will be shutting down as of December 28th, 2019. If you have content that you wish to keep, you should make a copy of it before that date.


SORTING HAT - Part 1: Building a Harry Potter style Sorting Hat using IBM Watson Services

Recommended By

  • Chris Tennant
POSTED IN: Data Analytics & Visualization Blog

The Mission:  To Build a Harry Potter style "Sorting Hat" that can sort the wearer into their "house"

The wider plan requires hardware, microphones, speakers, power supplies, hat materials, motors, lights, and speech to text and text to speech services - plus (as my youngest pointed out) a "Brain"

However - for part 1 - before we began on all the work of hardware integration and other services, we needed to make sure the core decision matrix (cortex?) was up to the task was sorting.   


Sorting Hat - Background:

The Sorting Hat is a sentient Hogwarts artefact which magically determines to which of the four school Houses each new student is to be assigned.

These four Houses are

  1. Gryffindor (the brave and bold),
  2. Hufflepuff (the loyal and dependable),
  3. Ravenclaw (the clever and witty) and
  4. Slytherin (the ambitious and often nasty).  












More background here: http://harrypotter.wikia.com/wiki/Sorting_Hat


Natural Language Classifier (NLC) is a mechanism to understand the "intent behind text and returns a corresponding classification with associated confidence levels"


Need a sorting machine?  Find a classification machine :) 


The Video (raw footage, first test) 

Harry Potter "Sorting Hat" - this is a short (raw) video of a test of a Natural Language Classifier (NLC) running on IBM Watson that has been programmed up with a Ground Truth that was created by very enthusiastic 7 year old harry potter fan.  

Though it is relatively short, under 300 rows, and 4 classes, initially it seems to perform quite well against complex (and much longer) wikipedia entries for famous people - selected on the basis that they would probably have an obvious house selection (e.g. the Brainy Stephen Hawking should be sorted into the Brainy Ravenclaw house)


The wrapper was created in "R" (programming language) and is running in R Studio.  R is cycling through API calls to Watson - asking Watson NLC (Sorting Hat) to classify each Political Candidate or Famous figure below based on top sentences in Wikipedia.

  • Hillary Clinton - Ravenclaw (92%)
  • Joe Biden - Gryffindor (69%)
  • Donald Trump - Gryffindor (48%)
  • Ben Carson - Ravenclaw (65%)
  • Stephen Hawking - Ravenclaw (97%)
  • Jimmy Carter - Hufflepuff (54%)
  • Pete Seeger - Gryffindor (77%)

This is raw video, and the audio synch is a little off. Will post the source code when I get things tuned up a little more.

"All HP references, images and audio are property of publisher or studio. The opinions expressed are my own and do not reflect that of my employer."

Sorting Hat PART 2: https://dreamtolearn.com/ryan/data_analytics_viz/98


Interested in more content by this author?

About the Author

Ryan Anderson

Ryan Anderson

Hi! I like to play with data, analytics and hack around with robots and gadgets in my garage. Lately I've been learning about machine learning.

About this blog

Description is...<br/>Data Analytics & Visualization Blog - Generating insights from Data since 2013

Created: July 25, 2014


Up Next