exampletable2.py

来自「orange源码 数据挖掘技术」· Python 代码 · 共 40 行

PY
40
字号
# Description: Shows how to use ExampleTable.select and ExampleTable.getitems for sampling
# Category:    basic classes, sampling
# Classes:     ExampleTable, MakeRandomIndices, MakeRandomIndicesCV
# Uses:        
# Referenced:  ExampleTable.htm

import orange

domain = orange.Domain([orange.FloatVariable()])
data = orange.ExampleTable(domain)
for i in range(10):
    data.append([i])

for d in data:
    print d,
print "\n"

cv_indices = orange.MakeRandomIndicesCV(data, 4)
print "Indices: ", cv_indices, "\n"

for fold in range(4):
    train = data.select(cv_indices, fold, negate = 1)
    test  = data.select(cv_indices, fold)
    print "Fold %d: train " % fold
    for ex in train:
        print "    ", ex
    print
    print "      : test  "
    for ex in test:
        print "    ", ex
    print

t = data.select([1, 1, 0, 0, 0,  0, 0, 0, 0, 1])
for ex in t:
    print ex

e = data.getitems([0, 1, 9])
for ex in e:
    print ex

⌨️ 快捷键说明

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