pp-select.py

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

PY
28
字号
# Description: Shows how to remove or select examples by values of attributes
# Category:    preprocessing
# Classes:     Preprocessor, Preprocessor_take, Preprocessor_drop
# Uses:        lenses
# Referenced:  preprocessing.htm

import orange
data = orange.ExampleTable("lenses")
age, prescr, astigm, tears, y = data.domain.variables

print "\n\nSelecting examples that have prescription 'hypermetrope' and are 'young' or 'pre-presbyopic'\n"
pp = orange.Preprocessor_take()
pp.values[prescr] = "hypermetrope"
pp.values[age] = ["young", "pre-presbyopic"]
data2 = pp(data)

for ex in data2:
    print ex

print "\n\nRemoving examples that have prescription 'hypermetrope' and are 'young' or 'pre-presbyopic'\n"
pp = orange.Preprocessor_drop()
pp.values[prescr] = "hypermetrope"
pp.values[age] = ["young", "pre-presbyopic"]
data2 = pp(data)

for ex in data2:
    print ex

⌨️ 快捷键说明

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