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

📄 example2.py

📁 orange源码 数据挖掘技术
💻 PY
字号:
# Description: Shows how to use meta-attributes with orange.Example
# Category:    basic classes, meta-attributes
# Classes:     Example
# Uses:        lenses
# Referenced:  Example.htm

import orange, random

random.seed(0)

data = orange.ExampleTable("lenses")

id = -42
# Note that this is wrong. Id should be assigned by
# id = orange.newmetaid()
# We only do this so that the script gives the same output each time it's run

for example in data:
    example[id] = orange.Value(random.random())

print data[0]

print orange.getClassDistribution(data)
print orange.getClassDistribution(data, id)

w = orange.FloatVariable("w")
data.domain.addmeta(id, w)

print data[0]

print data[0][id]
print data[0][w]
print data[0]["w"]

data[0][id] = orange.Value(w, 2.0)
data[0][id] = "2.0"
data[0][id] = 2.0

⌨️ 快捷键说明

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