# Encode a tree into a machine learning feature

I am creating/working with a dataset in order to answer all kind of questions using machine learning algorithms. One specific issue is that I would like to create a new feature based on a tree represented as one JSON file per sample.

Basically, the goal is :

tree in a JSON format -> number representing that tree


The naive approach would be take a hash of the tree representation. That would return a set of hashes and we can detect when the tree is different. However, I would like to have a sort of distance metrics saying how different the trees are.

I found some research on graph similarity metrics and it might be a way to go, by taking a random tree as the base one and compute the similarity with all the other ones.

But I wonder if this problem has already appeared in the past and if there is a known solution.