code: def balance(df):
      print("Balancing the classes")
      type_counts = df["Sentiment"].value_counts()
      min_count = min(type_counts.values)
  
      balanced_df = None
      for key in type_counts.keys():
          df_sub = df[df["Sentiment"] == key].sample(
              n=min_count, replace=False
          )
          if balanced_df is not None:
              balanced_df = balanced_df.append(df_sub)
          else:
              balanced_df = df_sub
      return balanced_df
  
file_path: nlp-architect/nlp_architect/utils/generic.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import re
  import numpy
label_desc: Use image node_id 8 for calling a global function with example usage: balance(df) and returns: balanced_df