Where is the "tree"? in the first line of code
When I ran this line of code at the beginning of this lesson:
clf = tree.DecisionTreeClassifier(random_state=365)
I got an error saying it can't find "tree". What is going on?
This just depends on your imports.
You have 2 options:
from sklearn import tree clf = tree.DecisionTreeClassifier(random_state=365)
from sklearn.tree import DecisionTreeClassifier clf = DecisionTreeClassifier(random_state=365)
So, as you can see, if you import only the "tree" part, you need to have tree.DecisionTreeClassifier, but if you import the DecisionTreeClassifier itself, you should leave out the "tree" in front.
Hope this helps!
Nikola, 365 Team