我已经设置了Orange并尝试在这段代码中执行PythonWin
在第二行得到了错误
我的橘子是不完整的还是别的什么东西?
>>> from Orange.data import *
>>> color = DiscreteVariable("color", values=["orange", "green", "yellow"])
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
NameError: name 'DiscreteVariable' is not defined发布于 2015-09-09 09:20:58
我不知道博客里的人在做什么,或者他在之前的博客文章中解释了其他一些步骤,但是这个代码“原样”是行不通的。
我在源代码中搜索Orange,而DiscreteVariable在任何地方都没有提到,没有作为类,也不是普通的单词,什么都没有。
然而,我发现
Discrete = core.EnumVariable在Orange/feature/__init__.py中。如您所见,这点指向core.EnumVariable,它出现在it's usage上
orange.EnumVariable('color', values = ["green", "red"])\与链接中的DiscreteVariable相同。
所以我建议你用from Orange.feature import Discrete代替,然后使用它。
https://stackoverflow.com/questions/32474522
复制相似问题