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

📄 domain13.py

📁 orange源码 数据挖掘技术
💻 PY
字号:
# Description: Adds two new numerical attributes to iris data set, and tests through cross validation if this helps in boosting classification accuracy
# Category:    modelling
# Uses:        iris
# Classes:     Domain, FloatVariable, MakeRandomIndicesCV, orngTest.testWithIndices
# Referenced:  domain.htm

import orange, orngTest, orngStat, orngTree
data = orange.ExampleTable('iris')

sa = orange.FloatVariable("sepal area")
sa.getValueFrom = lambda e, getWhat: e['sepal length'] * e['sepal width']
pa = orange.FloatVariable("petal area")
pa.getValueFrom = lambda e, getWhat: e['petal length'] * e['petal width']

newdomain = orange.Domain(data.domain.attributes+[sa, pa, data.domain.classVar])
newdata = data.select(newdomain)

learners = [orngTree.TreeLearner(mForPruning=2.0)]

indices = orange.MakeRandomIndicesCV(data, 10)
res1 = orngTest.testWithIndices(learners, data, indices)
res2 = orngTest.testWithIndices(learners, newdata, indices)

print "original: %5.3f, new: %5.3f" % (orngStat.CA(res1)[0], orngStat.CA(res2)[0])

⌨️ 快捷键说明

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