code: def plot_segmentation_results(
      flags_ind, flags_ind_gt, class_names, mt_step, evaluate_only=False
  ):
      """
      This function plots statistics on the classification-segmentation results
      produced either by the fix-sized supervised method or the HMM method.
      It also computes the overall accuracy achieved by the respective method
      if ground-truth is available.
      """
  
      flags = [class_names[int(f)] for f in flags_ind]
      segments, classes = labels_to_segments(flags, mt_step)
      min_len = min(flags_ind.shape[0], flags_ind_gt.shape[0])
      if min_len > 0:
          accuracy = np.sum(
              flags_ind[0:min_len] == flags_ind_gt[0:min_len]
          ) / float(min_len)
      else:
          accuracy = -1
  
      if not evaluate_only:
          duration = segments[-1, 1]
          s_percentages = np.zeros((len(class_names),))
          percentages = np.zeros((len(class_names),))
          av_durations = np.zeros((len(class_names),))
  
          for i_seg in range(segments.shape[0]):
              s_percentages[class_names.index(classes[i_seg])] += (
                  segments[i_seg, 1] - segments[i_seg, 0]
              )
  
          for i in range(s_percentages.shape[0]):
              percentages[i] = 100.0 * s_percentages[i] / duration
              class_sum = sum(1 for c in classes if c == class_names[i])
              if class_sum > 0:
                  av_durations[i] = s_percentages[i] / class_sum
              else:
                  av_durations[i] = 0.0
  
          for i in range(percentages.shape[0]):
              print(class_names[i], percentages[i], av_durations[i])
  
          font = {"size": 10}
          plt.rc("font", **font)
  
          fig = plt.figure()
          ax1 = fig.add_subplot(211)
          ax1.set_yticks(np.array(range(len(class_names))))
          ax1.axis((0, duration, -1, len(class_names)))
          ax1.set_yticklabels(class_names)
          ax1.plot(
              np.array(range(len(flags_ind))) * mt_step + mt_step / 2.0,
              flags_ind,
          )
          if flags_ind_gt.shape[0] > 0:
              ax1.plot(
                  np.array(range(len(flags_ind_gt))) * mt_step
                  + mt_step / 2.0,
                  flags_ind_gt + 0.05,
                  "--r",
              )
          plt.xlabel("time (seconds)")
          if accuracy >= 0:
              plt.title("Accuracy = {0:.1f}%".format(100.0 * accuracy))
  
          ax2 = fig.add_subplot(223)
          plt.title("Classes percentage durations")
          ax2.axis((0, len(class_names) + 1, 0, 100))
          ax2.set_xticks(np.array(range(len(class_names) + 1)))
          ax2.set_xticklabels([" "] + class_names)
          print(np.array(range(len(class_names))), percentages)
          ax2.bar(np.array(range(len(class_names))) + 0.5, percentages)
  
          ax3 = fig.add_subplot(224)
          plt.title("Segment average duration per class")
          ax3.axis((0, len(class_names) + 1, 0, av_durations.max()))
          ax3.set_xticks(np.array(range(len(class_names) + 1)))
          ax3.set_xticklabels([" "] + class_names)
          ax3.bar(np.array(range(len(class_names))) + 0.5, av_durations)
          fig.tight_layout()
          plt.show()
      return accuracy
  
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 7 for calling a global function with example usage: plot_segmentation_results(flags_ind, flags_ind_gt, class_names, mt_step, evaluate_only) and returns: accuracy