sklearn python 错误。标识符中的无效字符
sklearn python error. invalid character in identifier
from sklearn import tree
features = [[140, 1], [130, 1], [150, 0], [170, 0]] # 1- smooth 0 - bumpy
labels = [0, 0, 1, 1] # 0 - apple 1 - orange
clf = tree.DecisionTreeClassifier()
clf = clf.fit(features, labels)
print (clf.predict([[150, 0]]))
我想要的是制作一个简单的第一个机器学习应用程序,它可以告诉我水果是橙子还是苹果。在 运行 之后它向我展示了这个:
Traceback (most recent call last):
File "C:/Users/ursac/Desktop/hello world.py", line 1, in <module>
from sklearn import tree
File "C:\Users\ursac\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\__init__.py", line 134, in <module>
from .base import clone
File "C:\Users\ursac\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\base.py", line 11, in <module>
from scipy import sparse
ModuleNotFoundError: No module named 'scipy'
但我已经在 cmd
中使用 pip install sklearn
安装了 sklearn
请帮助我。谢谢 !
尝试安装 scipy
,因为它抱怨缺少该模块。
pip install scipy
安装 scipy
/numpy
。作为旁注 - 如果有人有旧的和新的 python - 那么应该使用 pip3
,因为在这种情况下 pip
为 python 2 安装模块。
from sklearn import tree
features = [[140, 1], [130, 1], [150, 0], [170, 0]] # 1- smooth 0 - bumpy
labels = [0, 0, 1, 1] # 0 - apple 1 - orange
clf = tree.DecisionTreeClassifier()
clf = clf.fit(features, labels)
print (clf.predict([[150, 0]]))
我想要的是制作一个简单的第一个机器学习应用程序,它可以告诉我水果是橙子还是苹果。在 运行 之后它向我展示了这个:
Traceback (most recent call last):
File "C:/Users/ursac/Desktop/hello world.py", line 1, in <module>
from sklearn import tree
File "C:\Users\ursac\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\__init__.py", line 134, in <module>
from .base import clone
File "C:\Users\ursac\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\base.py", line 11, in <module>
from scipy import sparse
ModuleNotFoundError: No module named 'scipy'
但我已经在 cmd
中使用pip install sklearn
安装了 sklearn
请帮助我。谢谢 !
尝试安装 scipy
,因为它抱怨缺少该模块。
pip install scipy
安装 scipy
/numpy
。作为旁注 - 如果有人有旧的和新的 python - 那么应该使用 pip3
,因为在这种情况下 pip
为 python 2 安装模块。