Commit a5ac8ad2 authored by bogdan's avatar bogdan

Tree Visualization widget

parent f0462cb1
This diff is collapsed.
......@@ -494,9 +494,9 @@ def svmeasy(input_dict):
return output_dict
def class_tree(input_dict):
import orange
import Orange
output_dict = {}
output_dict['treeout']= orange.TreeLearner(name = "Classification Tree (Orange)")
output_dict['treeout']= Orange.classification.tree.TreeLearner(name = "Classification Tree (Orange)")
return output_dict
def c45_tree(input_dict):
......@@ -840,3 +840,6 @@ def alter_table_finished(postdata, input_dict, output_dict):
except: # Catch orange exception and give a proper error message.
raise Exception("Illegal value '%s' for discrete attribute '%s', legal values are: %s." % (new_value, att, new_table.domain[att].values))
return {'altered_data' : new_table}
def tree_visualization(input_dict):
return{}
\ No newline at end of file
......@@ -267,7 +267,7 @@ class AbstractWidget(models.Model):
i.uid = uuid.uuid4()
if commit:
i.save()
for option in i:
for option in i.options.all():
option.uid = uuid.uuid4()
if commit:
option.save()
......
<div id="widgetvisualization-{{widget.pk}}" rel="{{widget.pk}}" width="900" height="600" class="widgetvisualizationdialog" title="{{widget.name}}">
{{ svg|safe }}
</div>
\ No newline at end of file
......@@ -191,3 +191,30 @@ def sdmsegs_viewer(request,input_dict,output_dict,widget):
}
output_dict = {'json_output':output}
return render(request, 'visualizations/sdmsegs_viewer.html',{'widget':widget,'input_dict':input_dict,'output_dict':output_dict})
def tree_visualization(request, input_dict, output_dict, widget):
import Orange
import pydot
import tempfile
f = tempfile.NamedTemporaryFile(delete=False,suffix='.dot')
tree = input_dict['clt']
tree.dot(f, leaf_shape="oval", node_shape="box")
f.close()
dot_file = open(f.name,"r")
dot_data = dot_file.read()
tree_visualization_graph = pydot.graph_from_dot_data(dot_data)
tree_visualization_graph.set_name("TreeVisualization")
tree_visualization_graph.set_size("9")
tree_visualization_graph.set_ratio("fill")
tree_visualization = tree_visualization_graph.create_svg()
return render(request, 'visualizations/tree_visualization.html', {'widget':widget, 'input_dict':input_dict, 'svg':tree_visualization})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment