'Graphviz and Weka only generates empty trees

I downloaded Graphviz and installed their package for Weka 3.9, created the props file as indicated on https://github.com/fracpete/graphviz-treevisualize-weka-package with content:

Executable="C:\Program Files (x86)\Graphviz2.38\bin\dot.exe" (Tried with and without quotation marks)

And it will only generate empty trees through plugin->visualize tree (Graphviz).

I'm in a bit of stress because I need to deliver a project by this night and discovered an error last moment, can anyone please help? I can deliver without the trees, but theyd be a major help.

Thanks in advance!



Solution 1:[1]

First of all, thanks for bringing this useful Weka plugin to my notice! I think it's written by one of the Weka developers fwiw, not by the authors of Graphviz.

To answer your question, although it's too late for your deadline sorry, are you sure you have created the props file correctly? In particular, the format for specifying the executable path is shown on the project page you linked to as (for example):

Executable=C:/Program Files (x86)/Graphviz2.38/bin/dot.exe

i.e. with forward slashes as the path separator, even on Windows. When I replaced the forward slashes with backslashes it gave me an empty window too, so I suspect this might be your problem.

However, in the absence of the plugin it's quite easy to write the Graphviz code for a decision tree structure by hand from the Weka output, and not too hard to code up a script to convert one to the other. Here's an example:

digraph myTree {
Node_1 [label="Predictor1"]
Node_1 -> Node_2 [label="<= 3.14"]
Node_1 -> Node_3 [label="> 3.14"]
Node_2 [label="Class 1", shape=box,style=filled,color=lightgray]
Node_3 [label="Predictor2"]
Node_3 -> Node_4 [label="<= 42"]
Node_3 -> Node_5 [label="> 42"]
Node_4 [label="Class 2", shape=box,style=filled,color=lightgray]
Node_5 [label="Class 3", shape=box,style=filled,color=lightgray]
}

and the corresponding output, obtained e.g. from dot -Tpng -O path\to\myTree.gv:

tree output from Graphviz

Solution 2:[2]

I had this same problem, but on a Weka/GraphViz install with a new Apple M1 chip. The following worked for me:

  1. Install the new version of Homebrew for the Apple M1 chip.
  2. Install GraphViz. brew install graphviz
  3. Open Weka, from the GUI Chooser go to Tools/Package Manager.
  4. In the top right corner under 'Unofficial' hit the 'File/URL' button.
  5. Copy this address for the install (note, this is a bit hacky as it's the 2014 plugin, if anyone can help get the newer 2018 plugin to install I'd appreciate it but it kept failing for me): https://github.com/fracpete/graphviz-treevisualize-weka-package/releases/download/v2014.8.1/graphviz-treevisualize-2014.8.1.zip
  6. Search your computer for the file ‘GraphVizTreeVisualization.props’ and open it with a text editor.
  7. Change this text Executable=dot to Executable=/opt/homebrew/Cellar/graphviz/3.0.0/bin/dot and save the file.
  8. Copy that file and paste the file here: $[HOME]/wekafiles/props/GraphVizTreeVisualization.props
  9. Restart Weka

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 nekomatic
Solution 2 Alison Krauskopf