कौन सा ओएस आप चला सकता हूँ? क्या आपके पास graphviz
स्थापित है?
अपने उदाहरण में, StringIO()
वस्तु, डेटा की जांच एक ही रास्ता है, Graphviz डेटा रखता है यहाँ है:
...
>>> print out.getvalue()
digraph Tree {
0 [label="X[2] <= 2.4500\nerror = 0.666667\nsamples = 150\nvalue = [ 50. 50. 50.]", shape="box"] ;
1 [label="error = 0.0000\nsamples = 50\nvalue = [ 50. 0. 0.]", shape="box"] ;
0 -> 1 ;
2 [label="X[3] <= 1.7500\nerror = 0.5\nsamples = 100\nvalue = [ 0. 50. 50.]", shape="box"] ;
0 -> 2 ;
3 [label="X[2] <= 4.9500\nerror = 0.168038\nsamples = 54\nvalue = [ 0. 49. 5.]", shape="box"] ;
2 -> 3 ;
4 [label="X[3] <= 1.6500\nerror = 0.0407986\nsamples = 48\nvalue = [ 0. 47. 1.]", shape="box"] ;
3 -> 4 ;
5 [label="error = 0.0000\nsamples = 47\nvalue = [ 0. 47. 0.]", shape="box"] ;
4 -> 5 ;
6 [label="error = 0.0000\nsamples = 1\nvalue = [ 0. 0. 1.]", shape="box"] ;
4 -> 6 ;
7 [label="X[3] <= 1.5500\nerror = 0.444444\nsamples = 6\nvalue = [ 0. 2. 4.]", shape="box"] ;
3 -> 7 ;
8 [label="error = 0.0000\nsamples = 3\nvalue = [ 0. 0. 3.]", shape="box"] ;
7 -> 8 ;
9 [label="X[0] <= 6.9500\nerror = 0.444444\nsamples = 3\nvalue = [ 0. 2. 1.]", shape="box"] ;
7 -> 9 ;
10 [label="error = 0.0000\nsamples = 2\nvalue = [ 0. 2. 0.]", shape="box"] ;
9 -> 10 ;
11 [label="error = 0.0000\nsamples = 1\nvalue = [ 0. 0. 1.]", shape="box"] ;
9 -> 11 ;
12 [label="X[2] <= 4.8500\nerror = 0.0425331\nsamples = 46\nvalue = [ 0. 1. 45.]", shape="box"] ;
2 -> 12 ;
13 [label="X[0] <= 5.9500\nerror = 0.444444\nsamples = 3\nvalue = [ 0. 1. 2.]", shape="box"] ;
12 -> 13 ;
14 [label="error = 0.0000\nsamples = 1\nvalue = [ 0. 1. 0.]", shape="box"] ;
13 -> 14 ;
15 [label="error = 0.0000\nsamples = 2\nvalue = [ 0. 0. 2.]", shape="box"] ;
13 -> 15 ;
16 [label="error = 0.0000\nsamples = 43\nvalue = [ 0. 0. 43.]", shape="box"] ;
12 -> 16 ;
}
आप .dot file के रूप में यह लिख सकते हैं और छवि उत्पादन का उत्पादन कर सकते हैं, के रूप में स्रोत में पता चला है आप लिंक किए गए:
$ dot -Tpng tree.dot -o tree.png
(PNG प्रारूप उत्पादन)
हाय धन्यवाद! मैं उबंटू 12.04, पायथन संस्करण 2.7.3 का उपयोग कर रहा हूं। मैं सोच रहा था कि क्या वैसे भी मैं इसे पाइथन लिपि में कर सकता हूं, न कि कमांड लाइन में? – DjangoRocks
निश्चित रूप से, उपलब्ध [पाइथन बाइंडिंग्स को ग्राफविज़] में से एक को पकड़ें (https://www.google.com/search?q=python+graphviz+ बाइंडिंग) और आपको इसे पायथन खोल – theta
धन्यवाद से करने में सक्षम होना चाहिए! वह सहायक था! – DjangoRocks