所以我正在尝试机器学习,并遵循我在网上找到的教程。
由于某种原因,当我运行我的代码时,numpy 给了我一个错误,即使我没有导入该库。(我一直遇到麻质问题)
法典:
#!/usr/bin/env python
from sklearn import tree
#1 = smooth 0 = bumpy
features = [[140, 1], [130, 1], [150, 0], [170, 0]] #input
labels = ["apple", "apple", "orange", "orange"] #desired output
#0 = apple 1 = orange
clf = tree.DecisionTreeClassifier()
clf = clf.fit(features, labels)
print clf.predict([[160, 0]])
错误:
C:Windowssystem32cmd.exe /c (python ^<C:UsersmeAppDataLocalTemp22V
Ii532A.tmp)
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "E:Python27libsite-packagessklearn__init__.py", line 134, in <module
>
from .base import clone
File "E:Python27libsite-packagessklearnbase.py", line 9, in <module>
import numpy as np
File "E:Python27libsite-packagesnumpy__init__.py", line 142, in <module>
from . import add_newdocs
File "E:Python27libsite-packagesnumpyadd_newdocs.py", line 13, in <module
>
from numpy.lib import add_newdoc
File "E:Python27libsite-packagesnumpylib__init__.py", line 8, in <module
>
from .type_check import *
File "E:Python27libsite-packagesnumpylibtype_check.py", line 11, in <mod
ule>
import numpy.core.numeric as _nx
File "E:Python27libsite-packagesnumpycore__init__.py", line 21, in <modu
le>
from . import function_base
File "E:Python27libsite-packagesnumpycorefunction_base.py", line 7, in <
module>
from .numeric import (result_type, NaN, shares_memory, MAY_SHARE_BOUNDS,
ImportError: cannot import name shares_memory
shell returned 1
Hit any key to close this window...
谢谢
附言还在寻找一些教程建议,一个是机器学习和 NLP 会很棒
Numpy 是一个 scikitlearn 依赖项。这意味着SKlearn是在numpy之上制作的。创建一个虚拟环境是一个好主意,以便了解真正的问题是什么。
同样的代码对我有用,我可以告诉你预测是"橙色的"。 :P