code: def feature_extraction_train_regression(
      folder_name,
      mid_window,
      mid_step,
      short_window,
      short_step,
      model_type,
      model_name,
      compute_beat=False,
  ):
      """
      This function is used as a wrapper to segment-based audio
      feature extraction and classifier training.
      ARGUMENTS:
          folder_name:        path of directory containing the WAV files
                           and Regression CSVs
          mt_win, mt_step:        mid-term window length and step
          st_win, st_step:        short-term window and step
          model_type:        "svm" or "knn" or "randomforest"
          model_name:        name of the model to be saved
      RETURNS:
          None. Resulting regression model along with the respective
          model parameters are saved on files.
      """
      # STEP A: Feature Extraction:
      features, _, filenames = aF.multiple_directory_feature_extraction(
          [folder_name],
          mid_window,
          mid_step,
          short_window,
          short_step,
          compute_beat=compute_beat,
      )
      features = features[0]
      filenames = [ntpath.basename(f) for f in filenames[0]]
      f_final = []
  
      # Read CSVs:
      csv_files = glob.glob(folder_name + os.sep + "*.csv")
      regression_labels = []
      regression_names = []
      f_final = []
      for c in csv_files:
          cur_regression_labels = []
          f_temp = []
          # open the csv file that contains the current target value's annotations
          with open(c, "rt") as csvfile:
              csv_reader = csv.reader(
                  csvfile, delimiter=",", quotechar="|"
              )
              for row in csv_reader:
                  if len(row) == 2:
                      # ... and if the current filename exists
                      # in the list of filenames
                      if row[0] in filenames:
                          index = filenames.index(row[0])
                          cur_regression_labels.append(float(row[1]))
                          f_temp.append(features[index, :])
                      else:
                          print(
                              "Warning: {} not found "
                              "in list of files.".format(row[0])
                          )
                  else:
                      print(
                          "Warning: Row with unknown format in regression file"
                      )
  
          f_final.append(np.array(f_temp))
          # cur_regression_labels is the list of values
          # for the current regression problem
          regression_labels.append(np.array(cur_regression_labels))
          # regression task name
          regression_names.append(
              ntpath.basename(c).replace(".csv", "")
          )
          if len(features) == 0:
              print("ERROR: No data found in any input folder!")
              return
  
      # STEP B: classifier Evaluation and Parameter Selection:
      if model_type == "svm" or model_type == "svm_rbf":
          model_params = np.array(
              [0.001, 0.005, 0.01, 0.05, 0.1, 0.25, 0.5, 1.0, 5.0, 10.0]
          )
      elif model_type == "randomforest":
          model_params = np.array([5, 10, 25, 50, 100])
  
      errors = []
      errors_base = []
      best_params = []
  
      for iRegression, r in enumerate(regression_names):
          # get optimal classifeir parameter:
          print("Regression task " + r)
          bestParam, error, berror = evaluate_regression(
              f_final[iRegression],
              regression_labels[iRegression],
              100,
              model_type,
              model_params,
          )
          errors.append(error)
          errors_base.append(berror)
          best_params.append(bestParam)
          print("Selected params: {0:.5f}".format(bestParam))
  
          # scale the features (mean-std) and keep the mean/std parameters
          # to be saved with the model
          scaler = StandardScaler()
          features_norm = scaler.fit_transform(f_final[iRegression])
          mean = scaler.mean_.tolist()
          std = scaler.scale_.tolist()
  
          # STEP C: Save the model to file
          if model_type == "svm":
              classifier, _ = train_svm_regression(
                  features_norm,
                  regression_labels[iRegression],
                  bestParam,
              )
          if model_type == "svm_rbf":
              classifier, _ = train_svm_regression(
                  features_norm,
                  regression_labels[iRegression],
                  bestParam,
                  kernel="rbf",
              )
          if model_type == "randomforest":
              classifier, _ = train_random_forest_regression(
                  features_norm,
                  regression_labels[iRegression],
                  bestParam,
              )
  
          # Save the model to a file, along with
          # - the scaling -mean/std- vectors)
          # - the feature extraction parameters
          if (
              model_type == "svm"
              or model_type == "svm_rbf"
              or model_type == "randomforest"
          ):
              with open(model_name + "_" + r, "wb") as fid:
                  cPickle.dump(classifier, fid)
              save_path = model_name + "_" + r + "MEANS"
              save_parameters(
                  save_path,
                  mean,
                  std,
                  mid_window,
                  mid_step,
                  short_window,
                  short_step,
                  compute_beat,
              )
  
      return errors, errors_base, best_params
  
imports: from __future__ import print_function
  from imblearn.under_sampling import RandomUnderSampler
  from imblearn.over_sampling import SMOTE
  from sklearn.model_selection import GroupShuffleSplit
  from pyAudioAnalysis import audioBasicIO
  from pyAudioAnalysis import MidTermFeatures
  import sys
  import numpy
  import os
  import glob
  import pickle
  import csv
  import ntpath
  from scipy import linalg
  from scipy.spatial import distance
  import sklearn.svm
  import sklearn.decomposition
  import sklearn.ensemble
  import plotly
  import plotly.subplots
  import plotly.graph_objs
  import sklearn.metrics
  from sklearn.model_selection import train_test_split
  from sklearn.preprocessing import StandardScaler
label_desc: Use image node_id 12 for calling a global function with example usage: feature_extraction_train_regression(folder_name, mid_window, mid_step, short_window, short_step, model_type, model_name, compute_beat) and returns: errors,  errors_base,  best_params