code: def compute_metrics(confusion_matrix, class_names):
      """
      This function computes the precision, recall and f1 measures,
      given a confusion matrix
      """
      f1 = []
      recall = []
      precision = []
      n_classes = confusion_matrix.shape[0]
      if len(class_names) != n_classes:
          print(
              "Error in computePreRec! Confusion matrix and class_names "
              "list must be of the same size!"
          )
      else:
          for i, c in enumerate(class_names):
              precision.append(
                  confusion_matrix[i, i]
                  / np.sum(confusion_matrix[:, i])
              )
              recall.append(
                  confusion_matrix[i, i]
                  / np.sum(confusion_matrix[i, :])
              )
              f1.append(
                  2
                  * precision[-1]
                  * recall[-1]
                  / (precision[-1] + recall[-1])
              )
      return recall, precision, f1
  
imports: from __future__ import print_function
  import os
  import csv
  import glob
  import scipy
  import sklearn
  import numpy
  import hmmlearn.hmm
  import sklearn.cluster
  import pickle
  import matplotlib.pyplot
  from scipy.spatial import distance
  import sklearn.discriminant_analysis
  from sklearn.preprocessing import StandardScaler
  import sys
  import pyAudioAnalysis.audioBasicIO
  import pyAudioAnalysis.audioTrainTest
  import pyAudioAnalysis.MidTermFeatures
  import pyAudioAnalysis.ShortTermFeatures
label_desc: Use image node_id 5 for calling a global function with example usage: compute_metrics(confusion_matrix, class_names) and returns: recall,  precision,  f1