0

My textbooks tells me to use the following import statements:

from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier
from sklearn.model_selection import train_test_split, cross_val_score, GridSearchCV

Instead of doing all that can I simply do

import sklearn

Or if I can't just do that, can I just do

import sklearn.tree
import sklearn.ensemble
import sklearn.model_selection

I'd like to understand the differences. I want to understand how importing works and not just for sklearn. Are certain options faster or require less ram?

Thanks

AndrewGraham
  • 310
  • 1
  • 8
  • Did you try researching how python imports? I think that this is fairly documented. – Amit Singh Jan 01 '21 at 22:44
  • https://stackoverflow.com/questions/10501724/how-does-python-importing-exactly-work – Amit Singh Jan 01 '21 at 22:45
  • 3
    Does this answer your question? [How does Python importing exactly work?](https://stackoverflow.com/questions/10501724/how-does-python-importing-exactly-work) – Amit Singh Jan 01 '21 at 22:46
  • Hi Amit. I did try researching it and couldn't find the answer. I read through the links you posted and wasn't able to find it there either. I'm sure it exists on the internet, I just can't seem to find it. Someone in the thread you posted shared 5 links, I quickly looked at those and didn't see an answer but didn't fully read them. If you know the answer I would appreciate you sharing it. – AndrewGraham Jan 01 '21 at 22:49

0 Answers0