I have started using sckikit-learn for my work. So I was going through the tutorial which gives standard procedure to load some datasets:
$ python
>>> from sklearn import datasets
>>> iris = datasets.load_iris()
>>> digits = datasets.load_digits()
However, for my convenience, I tried loading the data in the following way:
In [1]: import sklearn
In [2]: iris = sklearn.datasets.load_iris()
However, this throws following error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-db77d2036db5> in <module>()
----> 1 iris = sklearn.datasets.load_iris()
AttributeError: 'module' object has no attribute 'datasets'
However, if I use the apparently similar method:
In [3]: from sklearn import datasets
In [4]: iris = datasets.load_iris()
It works without problem. In fact the following also works:
In [5]: iris = sklearn.datasets.load_iris()
I am completely confused about this. Am I missing something very trivial? What is the difference between the two approaches?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…