I am learning python and trying myself out at mashine learning. I am reproducing a super simple example - based on the infamous iris dataset. Here it goes:
from sklearn import datasets
iris = datasets.load_iris()
X = iris.data
y = iris.target
from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = .5)
from sklearn import tree
nordan_tree = tree.DecisionTreeClassifier()
nordan_tree.fit(X_train, y_train)
from sklearn.metrics import accuracy_score
I get the following error message:
Traceback (most recent call last):
File "tree3.py", line 17, in <module>
print(accuracy_score(y_test, predictions))
NameError: name 'predictions' is not defined
I don't get it. As far as I understand, predictions
is the vector containing all the predictions produced with DecisionTreeClassifier
? What am I doing wrong?