<p>Both weighting (cost-sensitive) and thresholding are valid forms of cost-sensitive learning.  In the briefest terms, you can think of the two as follows:</p>

<h1>Weighting</h1>

<p>Essentially one is asserting that the ‘cost’ of misclassifying the rare class is worse than misclassifying the common class.  This is <strong>applied at the algorithmic level</strong> in such algorithms as SVM, ANN, and Random Forest.  The limitations here consist of whether the algorithm can deal with weights.  Furthermore, many applications of this are trying to address the idea of making a more serious misclassification (e.g. classifying someone who has pancreatic cancer as non having cancer).  In such circumstances, you <strong>know</strong> why you want to make sure you classify specific classes even in imbalanced settings.  Ideally you want to optimize the cost parameters as you would any other model parameter.</p>

<h1>Thresholding</h1>

<p>If the algorithm returns <strong>probabilities</strong> (or some other score), thresholding can be <strong>applied after a model has been built</strong>.  Essentially you change the classification threshold from 50-50 to an appropriate trade-off level.  This typically can be optimized by generated a curve of the evaluation metric (e.g. F-measure).  The limitation here is that you are making absolute trade-offs.  Any modification in the cutoff will in turn decrease the accuracy of predicting the other class.  If you have exceedingly high probabilities for the majority of your common classes (e.g. most above 0.85) you are more likely to have success with this method.  It is also algorithm independent (provided the algorithm returns probabilities).</p>

<h1>Sampling</h1>

<p>Sampling is another common option applied to imbalanced datasets to bring some balance to the class distributions.  There are essentially two fundamental approaches.</p>

<p><strong><em>Under-sampling</em></strong></p>

<p>Extract a smaller set of the majority instances and keep the minority.  This will result in a smaller dataset where the distribution between classes is closer; however, you have discarded data that may have been valuable.  This could also be beneficial if you have a very large amount of data.</p>

<p><strong><em>Over-sampling</em></strong></p>

<p>Increase the number of minority instances by replicating them.  This will result in a larger dataset which retains all the original data but may introduce bias.  As you increase the size, however, you may begin to impact computational performance as well.</p>

<p><strong><em>Advanced Methods</em></strong></p>

<p>There are additional methods that are more ‘sophisticated’ to help address potential bias.  These include methods such as <a href="http://arxiv.org/pdf/1106.1813.pdf" rel="noreferrer">SMOTE</a>, <a href="http://www3.nd.edu/~nchawla/papers/ECML03.pdf" rel="noreferrer">SMOTEBoost</a> and <a href="http://cse.seu.edu.cn/people/xyliu/publication/tsmcb09.pdf" rel="noreferrer">EasyEnsemble</a> as referenced in this <a href="https://stats.stackexchange.com/questions/97926/suggestions-for-cost-sensitive-learning-in-a-highly-imbalanced-setting">prior question</a> regarding imbalanced datasets and CSL.</p>

<h1>Model Building</h1>

<p>One further note regarding building models with imbalanced data is that you should keep in mind your model metric.  For example, metrics such as F-measures don’t take into account the true negative rate.  Therefore, it is often recommended that in imbalanced settings to use metrics such as <a href="http://en.wikipedia.org/wiki/Cohen%27s_kappa" rel="noreferrer">Cohen’s kappa metric</a>.</p>
Dealing with the class imbalance in binary classification
<p>Here's a brief description of my problem:</p>

<ol>
<li>I am working on a <em>supervised learning</em> task to train a <em>binary</em> classifier. </li>
<li>I have a dataset with a large class <em>imbalance</em> distribution: 8 negative instances every one positive. </li>
<li>I use the <em>f-measure</em>, i.e. the harmonic mean between specificity and sensitivity, to assess the performance of a classifier.</li>
</ol>

<p>I plot the ROC graphs of several classifiers and all present a great AUC, meaning that the classification is good. However, when I test the classifier and compute the f-measure I get a really low value. I know that this issue is caused by the class skewness of the dataset and, by now, I discover two options to deal with it:</p>

<ol>
<li>Adopting a <strong>cost-sensitive</strong> approach by assigning weights to the dataset's instances (see this <a href="https://stackoverflow.com/questions/20082674/unbalanced-classification-using-randomforestclassifier-in-sklearn">post</a>)</li>
<li><strong>Thresholding</strong> the predicted probabilities returned by the classifiers, to reduce the number of false positives and false negatives.</li>
</ol>

<p>I went for the first option and that solved my issue (f-measure is satisfactory). BUT, now, my question is: which of these methods is preferable? And what are the differences?</p>

<p><em>P.S: I am using Python with the scikit-learn library.</em></p>