≡ Menu

Misusing Machine Learning for Fun

You can use a Decision Tree to compress an image. There are libraries to do this kind of thing properly, but I wanted to see what a Decision Tree “sees” when it looks at an image.

The training input is each pixel’s x, y position, and the channel number. The target is the value for that pixel and channel. I am not doing a test/train split because I’m not looking to build a model to predict anything, I’m looking to compress something.

And it worked. Here’s what it looks like for the black and white image:

animated gif showing the output of different decision tree depths. It goes from completely blank to a detailed representation of the Van Gogh self portrait.

And if you want to see a video where I go through a bit more of an explanation check it out here: