What are the common techniques for encoding discrete features with tree-path value (e.g. file/folder path) without expanding tree into multiple features corresponding to each node?
Overall, I am looking for encoding which can be used with different algorithms (e.g. linear regression, not only clustering). Something like Huffman coding but usable with machine learning.
For example, consider this tree described with lisp-like notation:
(a (b b1 b2) (c c1 c2 c3))
It could be encoded by creating feature for each node
but this will be very expensive for any sufficiently large tree.
a b b1 b2 c c1 c2 c3 Path
1 1 0 0 0 0 0 0 /a/b
1 0 0 0 1 0 1 0 /a/c/c2
Instead of creating feature for each node,
there could probably be a feature for each depth level.
L1 L2 L3 Path
1 1 0 /a/b
1 2 6 /a/c/c2
L2 can have value of 0,1,2 for none,b,c correspondingly;
L3 can have value of 0,1,2,5,6,7 for none,b1,b2,c1,c2,c3 correspondingly (with gap between b2, and c1 so that there is numerical distance between nodes with different parents).
There are some obvious problems with it though, e.g. c1 and c3 are further away from each other than c1 and c2.
I understand that encoding really depends on how you want to interpret the tree and relation between nodes. I was hoping there might be some article/paper which describes different approaches and trade-offs.