wekagraphviz

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

  • 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