This is the so-called "Class Imbalance Problem". Fortunately, there are a number of possible approaches.
Probably easiest is going to be to use the class_weight
option present in a number of scikit-learn's classifiers. For example, LogisticRegression.
You can either set this option to "balanced"
(or "auto"
if you're using an older version of sklearn), in which case it automatically adjusts weights inversely proportional to class frequency (i.e. it tries to compensate for the class imbalance); or you can manually set the weights for each class label using a dict, e.g. {0:1, 1: 20}
.
For a worked example using an SVM, see here.
See here for more information: http://stats.stackexchange.com/questions/131255/class-imbalance-in-supervised-machine-learninghttps://stats.stackexchange.com/questions/131255/class-imbalance-in-supervised-machine-learning