sklearn python错误。标识符中的无效字符

时间:2018-01-13 15:30:35

标签: python machine-learning tree python-3.6 sklearn-pandas

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

请帮帮我。谢谢 !

1 个答案:

答案 0 :(得分:1)

尝试安装scipy,因为它抱怨该模块丢失。

pip install scipy

安装scipy / numpy。作为旁注 - 如果某人有旧的和新的python - 那么应该使用pip3,因为pip在这种情况下为python 2安装模块。

相关问题