code: def confusionMatrix(df, y_col, y_hat_col, labels):
      from sklearn.metrics import confusion_matrix
      import matplotlib.pyplot as plt
  
      if isinstance(df, pyspark.sql.dataframe.DataFrame):
          df = df.select([y_col, y_hat_col]).toPandas()
  
      y, y_hat = df[y_col], df[y_hat_col]
      accuracy = np.mean(
          [
              1.0 if pred == true else 0.0
              for (pred, true) in zip(y_hat, y)
          ]
      )
      cm = confusion_matrix(y, y_hat)
      cmn = cm.astype("float") / cm.sum(axis=1)[:, np.newaxis]
      plt.text(
          -0.3,
          -0.55,
          "$Accuracy$ $=$ ${}\%$".format(round(accuracy * 100, 1)),
          fontsize=18,
      )
      tick_marks = np.arange(len(labels))
      plt.xticks(tick_marks, labels, rotation=0)
      plt.yticks(tick_marks, labels, rotation=90)
      plt.imshow(
          cmn,
          interpolation="nearest",
          cmap=plt.cm.Blues,
          vmin=0,
          vmax=1,
      )
  
      thresh = 0.1
      for i, j in itertools.product(
          range(cm.shape[0]), range(cm.shape[1])
      ):
          plt.text(
              j,
              i,
              cm[i, j],
              horizontalalignment="center",
              fontsize=18,
              color="white" if cmn[i, j] > thresh else "black",
          )
  
      plt.colorbar()
      plt.xlabel("Predicted Label", fontsize=18)
      plt.ylabel("True Label", fontsize=18)
  
file_path: SynapseML/core/src/main/python/synapse/ml/plot/plot.py
imports: import sys
  import pyspark
  from pyspark import SparkContext
  from pyspark import sql
  from pyspark.sql import DataFrame
  import warnings
  import numpy
  import itertools
label_desc: Use image node_id 1 for calling a global function with example usage: confusionMatrix(df, y_col, y_hat_col, labels) without return types