def report_tree(self, name): filename = name + '.tsv' stream = file(filename, 'wt') # header stream.write('\t'.join(self.names) + '\n') stream.write('\t'.join(self.types) + '\n') stream.write('class\n') # rows for row in self.rows: if row[0] == 'skip': continue row += [''] * (len(self.names) - len(row)) stream.write('\t'.join(row) + '\n') stream.close() # See http://www.ailab.si/orange/doc/ofb/c_otherclass.htm try: import orange import orngTree except ImportError: sys.stderr.write( 'Install Orange from http://www.ailab.si/orange/ for a classification tree.\n' ) return None data = orange.ExampleTable(filename) tree = orngTree.TreeLearner(data, sameMajorityPruning=1, mForPruning=2) orngTree.printTxt(tree, maxDepth=4) text_tree = orngTree.dumpTree(tree) file(name + '.txt', 'wt').write(text_tree) orngTree.printDot(tree, fileName=name + '.dot', nodeShape='ellipse', leafShape='box') return text_tree
def summary(self): sys.stdout.write("%u tests, %u passed, %u skipped, %u failed\n\n" % (self.tests, self.passed, self.skipped, self.failed)) sys.stdout.flush() name, ext = os.path.splitext(os.path.basename(sys.argv[0])) filename = name + '.tsv' stream = file(filename, 'wt') # header stream.write('\t'.join(self.names) + '\n') stream.write('\t'.join(self.types) + '\n') stream.write('class\n') # rows for row in self.rows: row += [''] * (len(self.names) - len(row)) stream.write('\t'.join(row) + '\n') stream.close() # See http://www.ailab.si/orange/doc/ofb/c_otherclass.htm try: import orange import orngTree except ImportError: sys.stderr.write( 'Install Orange from http://www.ailab.si/orange/ for a classification tree.\n' ) return data = orange.ExampleTable(filename) tree = orngTree.TreeLearner(data, sameMajorityPruning=1, mForPruning=2) orngTree.printTxt(tree, maxDepth=4) file(name + '.txt', 'wt').write(orngTree.dumpTree(tree)) orngTree.printDot(tree, fileName=name + '.dot', nodeShape='ellipse', leafShape='box')
def report_tree(self, name): filename = name + '.tsv' stream = file(filename, 'wt') # header stream.write('\t'.join(self.names) + '\n') stream.write('\t'.join(self.types) + '\n') stream.write('class\n') # rows for row in self.rows: if row[0] == 'skip': continue row += ['']*(len(self.names) - len(row)) stream.write('\t'.join(row) + '\n') stream.close() # See http://www.ailab.si/orange/doc/ofb/c_otherclass.htm try: import orange import orngTree except ImportError: sys.stderr.write('Install Orange from http://www.ailab.si/orange/ for a classification tree.\n') return None data = orange.ExampleTable(filename) tree = orngTree.TreeLearner(data, sameMajorityPruning=1, mForPruning=2) orngTree.printTxt(tree, maxDepth=4) text_tree = orngTree.dumpTree(tree) file(name + '.txt', 'wt').write(text_tree) orngTree.printDot(tree, fileName=name+'.dot', nodeShape='ellipse', leafShape='box') return text_tree
def summary(self): sys.stdout.write("%u tests, %u passed, %u skipped, %u failed\n\n" % (self.tests, self.passed, self.skipped, self.failed)) sys.stdout.flush() name, ext = os.path.splitext(os.path.basename(sys.argv[0])) filename = name + '.tsv' stream = file(filename, 'wt') # header stream.write('\t'.join(self.names) + '\n') stream.write('\t'.join(self.types) + '\n') stream.write('class\n') # rows for row in self.rows: row += ['']*(len(self.names) - len(row)) stream.write('\t'.join(row) + '\n') stream.close() # See http://www.ailab.si/orange/doc/ofb/c_otherclass.htm try: import orange import orngTree except ImportError: sys.stderr.write('Install Orange from http://www.ailab.si/orange/ for a classification tree.\n') return data = orange.ExampleTable(filename) tree = orngTree.TreeLearner(data, sameMajorityPruning=1, mForPruning=2) orngTree.printTxt(tree, maxDepth=4) file(name+'.txt', 'wt').write(orngTree.dumpTree(tree)) orngTree.printDot(tree, fileName=name+'.dot', nodeShape='ellipse', leafShape='box')
#!/usr/bin/env python # # See also: # http://www.ailab.si/orange/doc/ofb/c_otherclass.htm import os.path import sys import orange import orngTree for arg in sys.argv[1:]: name, ext = os.path.splitext(arg) data = orange.ExampleTable(arg) tree = orngTree.TreeLearner(data, sameMajorityPruning=1, mForPruning=2) orngTree.printTxt(tree) file(name + '.txt', 'wt').write(orngTree.dumpTree(tree) + '\n') orngTree.printDot(tree, fileName=name + '.dot', nodeShape='ellipse', leafShape='box')
#!/usr/bin/env python # # See also: # http://www.ailab.si/orange/doc/ofb/c_otherclass.htm import os.path import sys import orange import orngTree for arg in sys.argv[1:]: name, ext = os.path.splitext(arg) data = orange.ExampleTable(arg) tree = orngTree.TreeLearner(data, sameMajorityPruning=1, mForPruning=2) orngTree.printTxt(tree) file(name+'.txt', 'wt').write(orngTree.dumpTree(tree) + '\n') orngTree.printDot(tree, fileName=name+'.dot', nodeShape='ellipse', leafShape='box')