There are 2 Techniques:

 1. **Oversampling**: There are many techniques under this, **ROSE** and **SMOTE** are the most famous techniques used for oversampling. In ROSE it just increases the minority classes. In SMOTE it synthetically generates more number of rare minority classes for balancing. Most of the Scenarios SMOTE gives better results than ROSE but you should try both. Other than that there is just another techniques which just duplicates the records to the make it equal n number. This [Link][1], is for implemenation of SMOTE in Python.

 2. **UnderSampling**: There are many techniques under this too, but this [Link-1][2], [Link-2][3] gives you better idea about undersampling. Generally I don't prefer Undersampling, as you would loose some infomation.

Do have a look and Let me know if you have any additional questions.

  [1]: https://github.com/scikit-learn-contrib/imbalanced-learn
  [2]: http://contrib.scikit-learn.org/imbalanced-learn/stable/auto_examples/applications/plot_multi_class_under_sampling.html
  [3]: https://datascience.stackexchange.com/questions/11404/python-handling-imbalance-classes-in-python-machine-learning