⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 domain7.py

📁 orange源码 数据挖掘技术
💻 PY
字号:
# Description: Shows how to add class noise and missing attributes to data sets. Also shows how to test a single learner on a range of data sets.
# 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
  if len(data):
    print "p(%s)=%5.3f" % (data.domain.classVar.values[0], float(n)/len(data))
  else:
    print

filename = "../datasets/adult_sample.tab"
data = orange.ExampleTable(filename)
report_prob('data', data)

selection = [1]*10 + [0]*(len(data)-10)
data1 = data.select(selection)
report_prob('data1, first ten instances', data1)

data2 = data.select(selection, negate=1)
report_prob('data2, other than first ten instances', data2)

selection = [1]*12 + [2]*12 + [3]*12 + [0]*(len(data)-12*3)
data3 = data.select(selection, 3)
report_prob('data3, third dozen of instances', data3)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -