code: def evaluate_segmentation_classification_dir(
      dir_name, model_name, method_name
  ):
      accuracies = []
      class_names = []
      cm_total = np.array([])
      for index, wav_file in enumerate(
          glob.glob(dir_name + os.sep + "*.wav")
      ):
          print(wav_file)
  
          gt_file = wav_file.replace(".wav", ".segments")
  
          if method_name.lower() in [
              "svm",
              "svm_rbf",
              "knn",
              "randomforest",
              "gradientboosting",
              "extratrees",
          ]:
              (
                  flags_ind,
                  class_names,
                  accuracy,
                  cm_temp,
              ) = mid_term_file_classification(
                  wav_file, model_name, method_name, False, gt_file
              )
          else:
              (
                  flags_ind,
                  class_names,
                  accuracy,
                  cm_temp,
              ) = hmm_segmentation(wav_file, model_name, False, gt_file)
          if accuracy > 0:
              if not index:
                  cm_total = np.copy(cm_temp)
              else:
                  cm_total = cm_total + cm_temp
              accuracies.append(accuracy)
              print(cm_temp, class_names)
              print(cm_total)
  
      if len(cm_total.shape) > 1:
          cm_total = cm_total / np.sum(cm_total)
          rec, pre, f1 = compute_metrics(cm_total, class_names)
  
          print(
              " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "
          )
          print(
              "Average Accuracy: {0:.1f}".format(
                  100.0 * np.array(accuracies).mean()
              )
          )
          print(
              "Average recall: {0:.1f}".format(
                  100.0 * np.array(rec).mean()
              )
          )
          print(
              "Average precision: {0:.1f}".format(
                  100.0 * np.array(pre).mean()
              )
          )
          print(
              "Average f1: {0:.1f}".format(100.0 * np.array(f1).mean())
          )
          print(
              "Median Accuracy: {0:.1f}".format(
                  100.0 * np.median(np.array(accuracies))
              )
          )
          print(
              "Min Accuracy: {0:.1f}".format(
                  100.0 * np.array(accuracies).min()
              )
          )
          print(
              "Max Accuracy: {0:.1f}".format(
                  100.0 * np.array(accuracies).max()
              )
          )
      else:
          print(
              "Confusion matrix was empty, accuracy for every file was 0"
          )
  
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 18 for calling a global function with example usage: evaluate_segmentation_classification_dir(dir_name, model_name, method_name) without return types