domain4.py
来自「orange源码 数据挖掘技术」· Python 代码 · 共 26 行
PY
26 行
# Description: Shows how to select examples based on their attribute values
# Category: preprocessing
# Uses: imports-85
# Referenced: domain.htm
import orange
def report_prob(header, data):
print 'Size of %s: %i instances' % (header, len(data))
n = 0
for i in data:
if int(i.getclass())==0:
n = n + 1
print "p(%s)=%5.3f" % (data.domain.classVar.values[0], float(n)/len(data))
filename = "../datasets/adult_sample.tab"
data = orange.ExampleTable(filename)
report_prob('original data set', data)
data1 = data.select(sex='Male')
report_prob('data1', data1)
data2 = data.select(sex='Male', education='Masters')
report_prob('data2', data2)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?