导入错误:无法导入名称预处理

时间:2018-09-09 12:35:53

标签: python-3.x scikit-learn pycharm importerror

从sklearn中输入

,同时导入集合,model_selection和预处理。 它显示导入错误。 (我正在研究Pycharm)

In [1]: A = np.array([np.arange(1,7),np.arange(7,13),np.arange(13,19),
                      np.arange(19,25),np.arange(25,31),np.arange(31,37)])

In [2]: A
Out[2]: 
array([[ 1,  2,  3,  4,  5,  6],
       [ 7,  8,  9, 10, 11, 12],
       [13, 14, 15, 16, 17, 18],
       [19, 20, 21, 22, 23, 24],
       [25, 26, 27, 28, 29, 30],
       [31, 32, 33, 34, 35, 36]])

In [3]: B = A[2, -3]

In [4]: B
Out[4]: 16

In [5]: B = A[::2,:]

In [6]: B
Out[6]: 
array([[ 1,  2,  3,  4,  5,  6],
       [13, 14, 15, 16, 17, 18],
       [25, 26, 27, 28, 29, 30]])

In [7]: B = A[:,::2]

In [8]: B
Out[8]: 
array([[ 1,  3,  5],
       [ 7,  9, 11],
       [13, 15, 17],
       [19, 21, 23],
       [25, 27, 29],
       [31, 33, 35]])

我已经安装了 Traceback (most recent call last): File "File path", line 4, in <module> from sklearn import ensemble, model_selection, preprocesing, tree ImportError: cannot import name 'preprocesing'

当前,我的解释器是虚拟环境,并且我正在阅读应更改路径的地方。我无法做到这一点,因为它说环境不是空的。在这方面的任何帮助将不胜感激

1 个答案:

答案 0 :(得分:-1)

这是因为它们是独立的模块。试试:

import sklearn.preprocessing
import sklearn.tree
import sklearn.ensemble

from sklearn.tree import DecisionTreeClassifier