📄 tree4.py
字号:
# Author: J Zabkar
# Version: 1.0
# Description: Storing and printing out the examples in classification tree
# Category: modelling
# Uses: iris.tab
# Referenced: orngTree.htm
import orange, orngTree
def printExamples(node):
if node:
if node.branches:
for b in node.branches:
printExamples(b)
else:
print "----------------- NEW NODE -----------------"
for ex in node.examples:
print ex
else:
print "null node"
data = orange.ExampleTable("iris.tab")
print len(data)
tree = orngTree.TreeLearner(data, storeExamples=1, storeContingencies=1)
print 'CLASSIFICATION TREE:'
orngTree.printTxt(tree)
print '\nEXAMPLES IN NODES:'
printExamples(tree.tree)
print '\nCONTINGENCY:'
print tree.tree.contingency.classes
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -