Code DAO
Code DAO
Jan 15, 2022 · Artificial Intelligence

Improving Class Imbalance in Machine Learning with Class Weights: A Python Logistic Regression Walkthrough

The article demonstrates, with Python code, how applying class_weight—first using the default logistic regression, then the balanced option, and finally manually tuned weights via grid search—can raise the F1 score from 0 to about 0.16 on imbalanced data, and discusses further techniques such as feature engineering and threshold adjustment.

F1 scorePythonclass weight
0 likes · 7 min read
Improving Class Imbalance in Machine Learning with Class Weights: A Python Logistic Regression Walkthrough