
Explore imbalanced classification in Python by applying data preparation techniques, learning models, and performance metrics to build practical, balanced classifiers for skewed class distributions.
Learn techniques for imbalanced classification, including selecting performance metrics, stratifying and splitting data, applying SMOTE-style sampling, exploring cost-sensitive methods, adapting SVM and decision trees, and tuning thresholds.
Explore the six core parts of imbalanced classification, from the foundation to data sampling, cost sensitivity, precision and recall, and advanced ensemble techniques with hands-on projects.
Explore imbalanced classification in predictive modeling, stressing how minority classes drive performance and how training data shape binary and multiclass problems.
Identify the causes of class imbalance in predictive modeling, including sampling bias and measurement errors, and understand how domain properties shape training data.
Explore the challenge of imbalance classification, distinguishing slight and severe imbalances, identifying majority and minority classes, and applying dataset-specific, specialized techniques to improve minority class predictions.
Explore examples of imbalanced and balanced classification across domains like fraud detection, churn prediction, and spam detection, highlighting how minority classes in binary classification drive detection challenges in predictive modeling.
Create and plot a binary imbalanced classification dataset to explore the impact of different class distributions, generate a synthetic dataset with skewed distributions, and visualize with matplotlib.
Explore skewed class distributions in binary classification with synthetic data, showing how majority and minority classes shape evaluation metrics and intuition across one to ten and one to one thousand.
Explore how extreme skew in imbalanced datasets shapes minority versus majority classes through visualizations of one-to-one and one-to-thousand distributions and related modeling challenges.
Understand why imbalanced classification is hard due to skewed class distributions and cost-sensitive errors. Examine how dataset size, label noise, and data distribution compound these challenges and affect evaluation metrics.
Explore the compounding effect of dataset size on imbalanced classification, demonstrating how minority class representation improves only at very large samples and how class distributions shape model learning.
Explore how label noise compounds imbalanced classification by corrupting minority class information and biasing decision boundaries toward the majority class, with demonstrations across noise levels.
Explore how data distribution compounds imbalanced classification, revealing how multiple clusters per class affect separability and generalization in real-world feature spaces.
Explore evaluation metrics for imbalanced classification, examine why accuracy can mislead, map metric taxonomy, and learn how to choose the right metric for predictive models.
Explore a taxonomy of classifier evaluation metrics for imbalanced classification, covering threshold, ranking, and probability metrics, with concepts like sensitivity, specificity, their geometric mean, precision, recall, and the f-measure.
Compare ranking metrics for imbalanced classification using rock curves and precision-recall curves. Assess threshold-based performance, minority class recall, and area under the rock curve to rank models.
Explore probabilistic metrics for imbalanced classification that quantify predictive uncertainty. Learn how log loss, cross entropy, and the Brier score assess calibrated probabilities across binary and multiclass tasks.
Explore how to choose evaluation metrics for imbalanced classification by aligning metrics with stakeholder goals, testing metrics on skewed scenarios, and considering thresholds, probabilities, and class importance.
Explore why accuracy fails for imbalanced classification, and how a skewed class distribution makes a single accuracy score misleading, emphasizing the need for balanced evaluation in Python models.
Explore the accuracy paradox in imbalanced data, where predicting the majority class yields 99% accuracy and hides poor minority performance, prompting use of alternative metrics.
Demonstrates why accuracy is misleading in imbalanced classification by showing a dummy majority-class predictor on a synthetic dataset, evaluated with stratified cross-validation, yielding a misleading 99% accuracy.
Explore precision in imbalanced classification by defining precision as the ratio of true positives to predicted positives, compare it to recall, and highlight how precision alone overlooks false negatives.
Explore how precision extends to multiclass problems, using true positives and false positives across minority and majority classes. Learn to compute precision with precision_score and micro averaging for imbalanced datasets.
Explore recall for imbalanced classification, defined as true positives over true positives plus false negatives, revealing coverage of positive classes. See binary and multiclass recall with minority to majority ratios.
Compute recall with the recall_score function for imbalanced binary and multiclass problems, analyzing true positives and false negatives, with example results including a multiclass recall around 0.86.
Explore precision and recall in imbalanced classification and show how the F measure, the harmonic mean of precision and recall (F1), combines them via an explicit minority–majority example.
Compute the F-measure for imbalanced classification in Python using a function, illustrated with a severe imbalance example and code that reproduces the manual F1 calculation with minor rounding differences.
Analyze ROC curves and precision recall curves to interpret probabilistic predictions in imbalanced two class classification, review the confusion matrix, and compare AUC across thresholds.
Visualize classifier performance with the ROC curve, plotting true positive rate against false positive rate to reveal threshold tradeoffs. Highlight imbalanced classification and thresholds, guiding discriminative power evaluation.
Explore ROC curves for imbalanced classification with a synthetic binary dataset, comparing a logistic regression model to no classifier and calculating the area under the curve.
Compute the area under the ROC curve (AUC) to compare binary classifiers across thresholds, especially for imbalanced problems, and note that precision-recall AUC offers an alternative.
Explore precision recall curves, defining precision as true positives over true positives plus false positives, and recall as true positives over true positives plus false negatives, across different thresholds.
Evaluate the precision-recall area under the curve score to compare binary classification models using the AUC function, illustrated with logistic regression on a synthetic dataset.
Explore ROC AUC and precision-recall curves for a severely imbalanced binary classifier, generating data with 99% and 1% weighting, stratified train-test splits, and a logistic regression baseline.
Analyze imbalanced binary classification using precision-recall curves and area under the curve (auc) score, illustrating how thresholding and predicted probabilities affect minority-class detection.
Explore probability scoring methods in Python to evaluate predictive probabilities in classification problems, covering three scoring rules, including log loss and the Breyer score.
calculate the average log loss for binary predictions in python, using true outcomes and probability estimates, and visualize with a line plot showing balanced versus unbalanced data.
Learn how the Brier score measures the mean squared error between predicted probabilities and actual outcomes, with Python examples using prior_score_loss, and compare performance on balanced versus imbalanced data.
Learn to evaluate classifiers on imbalanced data by using train-test splits or k-fold cross-validation, with stratified sampling to avoid optimistic or pessimistic performance estimates on unseen data.
Evaluate classifiers by estimating performance from available data, testing training/test splits, data preparation schemes, learning algorithms, and hyperparameters. Apply ten-fold cross-validation to obtain a less optimistic, robust performance estimate.
Demonstrate why k-fold cross-validation fails for imbalanced data due to scarce minority class examples. Show how folds and splits provide biased performance estimates and poor generalization.
Balance class distributions in imbalanced classification using data sampling methods, including over sampling techniques and their combinations, to enable standard models to learn from transformed data.
Explore oversampling techniques such as random oversampling, SMOTE, borderline SMOTE, borderline with SVM, and adaptive synthetic sampling to balance the minority and majority classes.
Explore under sampling techniques to balance imbalanced data by deleting or selecting majority-class examples. Learn random under sampling, near miss, Tomek links, edited nearest neighbors, and NCR/OSS combinations.
Explore combinations of data sampling techniques to improve model performance in imbalanced classification, using smote with random undersampling and editing steps with the edited nearest neighbors rule.
Explore random oversampling and random undersampling to create balanced training data for imbalanced classification, using naive resampling to achieve equal class distribution in binary and multiclass problems.
Apply random under sampling to balance imbalanced datasets by under sampling the majority class to match the minority class, and evaluate a decision tree in a pipeline with cross-validation.
Combine random oversampling and undersampling to improve imbalanced data performance by boosting the minority class and reducing the majority bias, demonstrated with a one to 100 distribution and cross-validated results.
Explore imbalanced classification with python by using smote to synthesize minority-class examples, fit and evaluate models on the smote-transformed data, and understand boundary-aware extensions.
Explore balancing an imbalanced binary classification with SMOTE, generating a synthetic dataset, fitting and transforming via the SMOTE class, and visualizing the resulting balanced distributions.
Apply SMOTE to balance data and evaluate imbalanced binary classification with a decision tree using three repeats of ten-fold cross-validation and ROC AUC, showing modest gains.
Apply borderline SMOTE to oversample only those minority class instances near decision boundaries that are misclassified by a K nearest neighbors model.
Explore adaptive synthetic sampling (ADASYN) to generate more minority samples in low-density regions and fewer in high-density areas, balancing imbalanced datasets. Evaluate its density-weighted focus against other SMOTE variants.
Explore undersampling methods for imbalanced classification, learning how to select samples to keep or delete, and how hybrids combine keeping and deleting strategies for balance.
Explore under sampling to balance a skewed binary dataset using near miss methods, especially near miss 1, 2, and 3, selecting majority samples by distance to minority neighbors.
Apply near miss undersampling with NearMiss-2 and NearMiss-3 to balance imbalanced data by selecting minority samples near the overlap and majority-class neighbors, demonstrated with code and the end-neighbors parameter.
Explore condensed nearest neighbor rule under sampling (CNN), which builds a minimal consistent set by keeping all minority samples and adding misclassified majority samples to balance and reduce KNN memory.
Explore Tomek links for undersampling to remove ambiguous boundary points. Identify cross-class nearest neighbors and apply with other methods to reduce redundancy without fully balancing the dataset.
Apply the edited nearest neighbors rule for under sampling to remove noisy and ambiguous class boundary points, using three neighbors by default, affecting both majority and minority classes.
Explore the neighborhood cleaning rule for undersampling, combining CNN and ENN to remove redundant and ambiguous examples, and balance data in binary classification.
Explore cost sensitive learning for imbalanced classification by recognizing that not all misclassification costs are equal, prioritizing false negatives and reviewing balanced classification and practical methods.
Explain how imbalanced binary classification creates skewed majority (negative) and minority (positive) classes, making misclassification costs unequal in real-world problems.
Explore cost sensitive learning, a field that handles uneven misclassification costs in imbalanced data, guiding models to minimize cost and loss on training data.
Explore cost-sensitive imbalanced classification by assigning misclassification costs via a cost matrix, and minimize total cost using confusion matrix insights, including false positives and false negatives.
Explore cost-sensitive methods using a cost matrix to tackle imbalanced classification, focusing on cost-sensitive resampling, algorithms, and ensembles, including under sampling and oversampling strategies.
Examine cost sensitive algorithms by applying a cost matrix to models and using training penalties, including class weight augmentations for decision trees, SVMs, logistic and ridge classifiers.
Explore cost-sensitive ensembles that wrap around standard classifiers to minimize misclassification costs, using threshold optimization in binary tasks, bagging to relabel the dataset, and cost-aware boosting of decision trees.
Explore cost-sensitive and weighted logistic regression for imbalanced classification, using class weighting to improve minority class performance in ambulance classification and prepare for grid search in practical datasets.
Explore logistic regression for imbalanced classification, using repeated ten-fold cross-validation and roc area under the curve evaluation, and apply class weighted or cost sensitive loss to emphasize minority classes.
Explore weighted logistic regression in scikit-learn, applying class_weight via inverse class distribution, and evaluate its performance with repeated cross-validation on synthetic data.
Perform a grid search over five class weightings for weighted logistic regression on imbalanced data, using repeated cross-validation to evaluate the r u c c score and identify optimal configuration.
Explore cost-sensitive decision trees for imbalanced classification, using weighted split points to account for minority class importance, and apply grid search to optimize decision trees.
Explore how decision trees handle imbalanced data by growing a cart, splitting to maximize purity using Gini impurity or entropy, and applying class-weighted, cost-sensitive splits.
Explore how to apply class weighting in scikit-learn's decision tree to handle imbalanced data, using inverse class distribution and cross-validated evaluation to boost performance.
Conduct a grid search over class weightings for a weighted decision tree on imbalanced data, using repeated cross-validation to identify the best configuration and its mean ROC score.
Develop a cost sensitive neural network for imbalanced classification by applying weighted backpropagation to pay more attention to the minority class in skewed datasets.
Construct a Keris neural network with ten hidden nodes and a sigmoid output to predict class labels, trained on a synthetic imbalanced dataset with stochastic gradient descent and cross-entropy loss.
Explore how deep learning handles imbalanced data by using cost-sensitive, weighted neural networks that assign higher errors to minority class examples, often inversely to class distribution.
Apply class weighting in Keras to imbalanced data across mlp, cnn, and rnn models. Use inverse class distribution with integers (1 for majority, 100 for minority) and evaluate improvements.
Develop a probabilistic model to predict breast cancer survival probabilities on the Habermann breast cancer data survival dataset, calibrate probabilities, evaluate models, and make predictions on new data.
Explore the Habermann dataset, a 306-example breast cancer survival dataset with three features—age at operation, year of operation, and number of positive auxiliary nodes—to study balanced classification and probabilistic predictions.
Load the dataset, compute a five-number summary, and visualize variable histograms to assess distributions, then examine the skewed class distribution and plan a test harness for model evaluation.
Evaluate candidate models using repeated stratified cross-validation, report bra score and prior skill score, and compare to a baseline prior strategy for predicting survival probabilities in an imbalanced dataset.
Evaluate six probabilistic models—including logistic regression and linear discriminant analysis—by comparing mean and distribution scores with box-and-whiskers plots to identify top performers.
Evaluate imbalanced classifications in Python by scaling inputs with standardization, using pipelines to apply a standard scaler, and performing cross-validated comparisons of probabilistic models like the Gaussian process classifier.
Apply power transforms, including Yeo-Johnson, in a pipeline to gaussianize features and improve model evaluation, using mad max scaling to handle zeros before transform while comparing clr, lda, and gcp.
Welcome to Imbalanced Classification Master Class in Python.
Classification predictive modeling is the task of assigning a label to an example. Imbalanced classification is those classification tasks where the distribution of examples across the classes is not equal. Typically the class distribution is severely skewed so that for each example in the minority class, there may be one hundred or even one thousand examples in the majority class. Practical imbalanced classification requires the use of a suite of specialized techniques, data preparation techniques, learning algorithms, and performance metrics.
Let's discuss what you'll learn in this course.
The challenge and intuitions for imbalanced classification datasets.
How to choose an appropriate performance metric for evaluating models for imbalanced classification.
How to appropriately stratify an imbalanced dataset when splitting into train and test sets and when using k-fold cross-validation.
How to use data sampling algorithms like SMOTE to transform the training dataset for an imbalanced dataset when fitting a range of standard machine learning models.
How algorithms from the field of cost-sensitive learning can be used for imbalanced classification.
How to use modified versions of standard algorithms like SVM and decision trees to take the class weighting into account.
How to tune the threshold when interpreting predicted probabilities as class labels.
How to calibrate probabilities predicted by nonlinear algorithms that are not fit using a probabilistic framework.
How to use algorithms from the field of outlier detection and anomaly detection for imbalanced classification.
How to use modified ensemble algorithms that have been modified to take the class distribution into account during training.
How to systematically work through an imbalanced classification predictive modeling project.
This course was created to be completed linearly, from start to finish. That being said, if you know the basics and need help with a specific method or type of problem, then you can flip straight to that section and get started. This course was designed for you to completed on your laptop or desktop, on the screen, not on a tablet.
My hope is that you have the course open right next to your editor and run the examples as you read about them. This course is not intended to be completed passively or be placed in a folder as a reference text. It is a playbook, a workbook, and a guidebook intended for you to learn by doing and then apply your new understanding with working Python examples. To get the most out of the course, I would recommend playing with the examples in each tutorial. Extend them, break them, then fix them.
Thanks for you interest in Imbalanced Classification Master Class in Python.
Now let's get started!