n scikit-learn, a lot of classifiers comes with a built-in method of handling imbalanced classes. If we have highly imbalanced classes and have no addressed it during preprocessing, we have the option of using the class_weight parameter to weight the classes to make certain we have a balanced mix of each class. Specifically, the balanced argument will automatically weigh classes inversely proportional to their frequency.
This video demonstrates the power class_weight=’balanced’
To view the video
- Click here
- Click on the image below