I'm about to mess around with Adaboost in sklearn
, but I just wanted to clarify a small difference that I'm having conceptually.
I've read through this stack overflow article. I've also breezed through some other stack articles with weird import errors. However, I'm still a little confused on why one of these snippets of code works, while the other breaks.
Basically, I'm just messing around with different ways to import sklearn.ensemble. I figured because sklearn is a package, we could do this:
import sklearn
clf = sklearn.ensemble.AdaBoostClassifier
AttributeError: 'module' object has no attribute 'ensemble'
The error tells me that ensemble is not an attribute. I guess this makes sense, because ensemble is itself a package.
This snipped of code works though:
import sklearn.ensemble
clf = sklearn.ensemble.AdaBoostClassifier
My question is, what is the distinction? If we import a package, shouldn't it be fine to reference packages within that super-package? Why would this not be allowed? Feel free to just link me documentation, but I wasn't sure about the best place to look.
Thank you!