I Give a Talk about Data Encoding

Among my software developer colleagues, there’s a lot of interest in machine learning with neural networks. Neural networks are essentially complex math functions, so if you have predictor variables that can take categorical values, like (red, yellow, blue, green), you must encode those values as numbers.

For neural networks, by far the most common way to encode categorical values, is 1-of-(N-1) encoding. For example, for a variable “color” that can be one of (red, yellow, blue, green):

red    = (  1,  0,  0 )
yellow = (  0,  1,  0 )
blue   = (  0,  0,  1 )
green  = ( -1, -1, -1 )

Notice that with N=4 possible values, the encoding only uses N-1 values of -1, 0, or +1. Pretty simple.

Developers sometimes seem to have difficulty with data encoding for neural networks. I suspect that the main source of this difficulty is that classical statistics uses data encoding too, but there are three common forms: dummy coding, effect coding, and orthogonal coding. And the “effect coding” used by classical statistics is exactly the same as the 1-of-(N-1) coding used in machine learning, but the motivations are slightly different. So when a developer searches the Internet for information about data encoding, he will quite likely end up with information for classical statistics encoding rather than encoding for machine learning.

In my talk I wondered about a possibility that I’ve never seen discussed — using the (statistics) orthogonal encoding technique for neural network predictor values. I strongly suspect that orthogonal encoding wouldn’t make any difference, either better or worse, but lots of things in machine learning are tricky, so only some experiments would reveal the truth for sure.


“The Papal Palace Avignon”, Paul Signac (1900)

This entry was posted in Machine Learning. Bookmark the permalink.

2 Responses to I Give a Talk about Data Encoding

  1. I have been looking for James McCaffrey. I have a “Design A Plane” Fighter series. Email me back if have a interest in it.

    4friend1@comcast.net

    • Hi Sharyn, I’m guessing you read a blog post I wrote about the Design A Plane construction kit I loved when I was young. I thank you but I’m not interested in getting one — for me the real pleasure is in the memory of Design A Plane, not the actual set itself. I’m kind of a minimalist when it comes to physical objects. I own very few “things” — I have two pair of shoes, four pair of pants, about eight shirts, eight pair of socks, and eight t-shirts. Other than that I can’t think of anything. No jewelry of any kind, no collections, etc. I spend all of my free money on experiences, such as trips or eating out.

Comments are closed.