title: Confusion Matrix in SkLearn showing error
body: <p>I am trying to plot a confusion matrix for my classification model given the iris dataset. However, I keep getting an error. I hope someone can guide.Thanks</p>
  
  <pre><code>import numpy as np
  from sklearn import datasets
  from sklearn.model_selection import train_test_split
  from sklearn import tree
  from sklearn import metrics
  from sklearn.metrics import confusion_matrix
  
  def train_and_predict(train_input_features, train_outputs, prediction_features):
      classifier=tree.DecisionTreeClassifier()
      classifier.fit(train_input_features,train_outputs)
      predictions=classifier.predict(prediction_features)
  
  
  iris = datasets.load_iris()
  X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target,test_size=0.3, random_state=0)
  
  y_pred = train_and_predict(X_train, y_train, X_test)
  print(confusion_matrix(y_test, predictions))
  </code></pre>
  
  <p>OUT: NameError: name 'predictions' is not defined</p>