class_docstr: Train the SVM for the low-shot image classification tasks. Currently,
  datasets like VOC07 and Places205 are supported.
  
  The trained inherits from the SVMTrainer class and takes care of
  training SVM, evaluating, and aggregate the metrics.
class_docstr_tok: ["Train","the","SVM","for","the","low-shot","image","classification","tasks",".","Currently",",","datasets","like","VOC07","and","Places205","are","supported",".","The","trained","inherits","from","the","SVMTrainer","class","and","takes","care","of","training","SVM",",","evaluating",",","and","aggregate","the","metrics","."]
docstr: Aggregate the test AP across all k-values and independent samples.
  
  For each low-shot k-value, we obtain the mean, max, min, std AP value.
  Steps:
      1. For each k-value, get the min/max/mean/std value across all the
         independent samples. This results in matrices [#k-values x #classes]
      2. Then we aggregate stats across the classes. For the mean stats in
         step 1, for each k-value, we get the class which has maximum mean.
docstr_tok: ["Aggregate","the","test","AP","across","all","k-values","and","independent","samples",".","For","each","low-shot","k-value",",","we","obtain","the","mean",",","max",",","min",",","std","AP","value",".","Steps",":","1",".","For","each","k-value",",","get","the","min\/max\/mean\/std","value","across","all","the","independent","samples",".","This","results","in","matrices","[","#","k-values","x","#","classes","]","2",".","Then","we","aggregate","stats","across","the","classes",".","For","the","mean","stats","in","step","1",",","for","each","k-value",",","we","get","the","class","which","has","maximum","mean","."]
code: def aggregate_stats(self, k_values, sample_inds):
      """
      Aggregate the test AP across all k-values and independent samples.
  
      For each low-shot k-value, we obtain the mean, max, min, std AP value.
      Steps:
          1. For each k-value, get the min/max/mean/std value across all the
             independent samples. This results in matrices [#k-values x #classes]
          2. Then we aggregate stats across the classes. For the mean stats in
             step 1, for each k-value, we get the class which has maximum mean.
      """
      logging.info(
          f"Aggregating stats for k-values: {k_values} and sample_inds: {sample_inds}"
      )
  
      output_mean, output_max, output_min, output_std = [], [], [], []
      for k_idx in range(len(k_values)):
          k_low = k_values[k_idx]
          k_val_output = []
          for inds in range(len(sample_inds)):
              sample_idx = sample_inds[inds]
              file_name = f"test_ap_sample{sample_idx}_k{k_low}.npy"
              filepath = f"{self.output_dir}/{file_name}"
              if g_pathmgr.exists(filepath):
                  k_val_output.append(load_file(filepath))
              else:
                  logging.info(f"file does not exist: {filepath}")
          k_val_output = np.concatenate(k_val_output, axis=0)
          k_low_max = np.max(k_val_output, axis=0).reshape(
              -1, k_val_output.shape[1]
          )
          k_low_min = np.min(k_val_output, axis=0).reshape(
              -1, k_val_output.shape[1]
          )
          k_low_mean = np.mean(k_val_output, axis=0).reshape(
              -1, k_val_output.shape[1]
          )
          k_low_std = np.std(k_val_output, axis=0).reshape(
              -1, k_val_output.shape[1]
          )
          output_mean.append(k_low_mean)
          output_min.append(k_low_min)
          output_max.append(k_low_max)
          output_std.append(k_low_std)
  
      output_mean = np.concatenate(output_mean, axis=0)
      output_min = np.concatenate(output_min, axis=0)
      output_max = np.concatenate(output_max, axis=0)
      output_std = np.concatenate(output_std, axis=0)
  
      self._save_stats(self.output_dir, "mean", output_mean)
      self._save_stats(self.output_dir, "min", output_min)
      self._save_stats(self.output_dir, "max", output_max)
      self._save_stats(self.output_dir, "std", output_std)
  
      argmax_cls = np.argmax(output_mean, axis=1)
      argmax_mean, argmax_min, argmax_max, argmax_std = [], [], [], []
      for idx in range(len(argmax_cls)):
          argmax_mean.append(100.0 * output_mean[idx, argmax_cls[idx]])
          argmax_min.append(100.0 * output_min[idx, argmax_cls[idx]])
          argmax_max.append(100.0 * output_max[idx, argmax_cls[idx]])
          argmax_std.append(100.0 * output_std[idx, argmax_cls[idx]])
      output_results = {}
      for idx in range(len(argmax_max)):
          logging.info(
              f"k-value: {k_values[idx]} mean/min/max/std: {round(argmax_mean[idx], 2)} "
              f"/ {round(argmax_min[idx], 2)} / "
              f"{round(argmax_max[idx], 2)} / "
              f"{round(argmax_std[idx], 2)}"
          )
          output_results[f"k={k_values[idx]}"] = {}
          output_results[f"k={k_values[idx]}"]["mean"] = round(
              argmax_mean[idx], 2
          )
          output_results[f"k={k_values[idx]}"]["min"] = round(
              argmax_min[idx], 2
          )
          output_results[f"k={k_values[idx]}"]["max"] = round(
              argmax_max[idx], 2
          )
          output_results[f"k={k_values[idx]}"]["std"] = round(
              argmax_std[idx], 2
          )
      logging.info("All done!!")
      return output_results
  
file_path: vissl/vissl/utils/svm_utils/svm_low_shot_trainer.py
imports: import logging
  import pickle
  import numpy
  from iopath.common.file_io import g_pathmgr
  from sklearn.svm import LinearSVC
  from vissl.utils.io import load_file, save_file
  from vissl.utils.svm_utils.evaluate import get_precision_recall
  from vissl.utils.svm_utils.svm_trainer import SVMTrainer
label_desc: Use image node_id 8 for calling the SVMLowShotTrainer obj's underlying member method code with example usage: obj.aggregate_stats(k_values, sample_inds) and returns: output_results