igrigorik / decisiontree

ID3-based implementation of the ML Decision Tree algorithm
1.44k stars 130 forks source link

Graph output unreadable #29

Closed DannyBen closed 7 years ago

DannyBen commented 7 years ago

Not sure if this nice gem is still maintained or not, I hope it is.

I am facing difficulties visualizing the tree. Using the dec_tree.graph method, I am getting an unreadable graph for any tree that is larger than the small examples.

Here is a small part of the image I get: screenshot

  1. I saw a probably similar issue at #28 .
  2. I have looked at this section of the code, to see if there are options I can pass (there aren't).
  3. I thought about generating my own graph, but I see that build_tree is private, and I am not yet sure how to get the nodes and their connections on my own.
  4. I saw in issue #11 that someone (you?) said "very few people use the actual graphing output" - so I wonder, how do most people generate a visual representation of their tree, if not with this function?

Am I missing something?

Thanks.

igrigorik commented 7 years ago

I don't think you're missing anything... :)

Graphing bits are not a well exercised path and could definitely be improved: we can extend the api with options, expose more options, etc. Would you be up for driving this?

DannyBen commented 7 years ago

I see.

I don't know if driving is the word I would use, but I can tell you that I definitely intend to make it work, I am just not sure my solution will be on par with your vision / expectations.

I am not familiar with the graphr gem, but my plan is this:

  1. See if there is an easy enhancement that can be done with the current graphr gem, for example, provide default options + an options hash.
  2. If so, and the output is pretty enough, will patch and PR.
  3. If not, will probably at least try to create an easy to traverse output from the tree (probably like the build_tree private method) so that anyone can get the nodes and push them to whatever graphing solution they want (e.g. dot).
  4. Finally, if 3 goes well, will add a method that generates a GraphViz dot syntax output and/or generates the GraphViz PNG itself.

If the above resonates, then I can promise to try to make my code presentable - otherwise, I will just patch it for my personal use.

Makes sense?

igrigorik commented 7 years ago

sounds great!

DannyBen commented 7 years ago

Fixed by #30