BHS Links
BHSLinks
Order

Canada — AI / 30-11-2026

Evaluating Models When the Classes Are Lopsided

Why Accuracy Lies When Classes Are Lopsided

A Toronto hospital network trains a model to flag sepsis risk in emergency patients. Ninety-four percent of encounters never develop sepsis, so a model that simply predicts "no sepsis" every time scores 94 percent accuracy and is completely useless. This is the central trap of imbalanced data, and it catches more Canadian teams than any other machine learning mistake.

The accuracy formula in machine learning — correct predictions divided by total predictions — rewards the majority class. When you have thousands of legitimate transactions against a handful of fraudulent ones, or millions of healthy claims against a small number of suspicious billings, accuracy flatters a model that has learned nothing. The first fix is editorial, not technical: stop reporting accuracy as your headline metric when the minority class is below roughly 10 percent of your data.

Instead, reach for precision, recall, F1, and the precision-recall curve. Recall tells you what share of real sepsis cases you caught; precision tells you how many alerts were genuine. A model that misses one in four cases may be unacceptable for a clinical alert regardless of its overall accuracy. Many teams also find the confusion matrix more useful than any single number, because it shows exactly which errors the model makes.

Resampling That Won't Leak Into Your Test Set

Oversampling minority cases and undersampling majority ones are the standard first moves, and they work — but only if you apply them inside the training fold. A common failure in Canadian data science teams is resampling the full dataset before splitting, which lets synthetic copies of the same case appear in both training and test sets. The model then looks brilliant offline and collapses in production.

Use SMOTE or a variant such as Borderline-SMOTE carefully; they interpolate new minority examples between existing ones and can fabricate unrealistic points when minority features are sparse. For categorical or free-text data, class weighting in the loss function is often cleaner than generating synthetic rows. Most modern libraries expose a setting like class_weight="balanced" that costs you nothing and avoids the leakage risk entirely.

A realistic pipeline for a Canadian payroll fraud dataset

Suppose a mid-sized employer in Mississauga has 1.2 million payroll line items from three years, and only 900 are confirmed fraudulent. A workable sequence: split by time, not randomly, so the test set is genuinely future data; fit the resampler only on training data; weight classes inversely to frequency; then evaluate on the untouched holdout. If your recall on the holdout is 0.6 with precision 0.3, you have a model worth tuning, not one worth deploying.

Consider procurement too: machine learning procurement software increasingly scores supplier risk, and the same imbalance logic applies when only a small fraction of suppliers default. The cost of a false negative (an unvetted supplier) rarely equals the cost of a false positive (a delayed onboarding), so tune your threshold against your actual business costs rather than a default 0.5 cutoff.

The Metrics and Tools Worth Your Time

Set a decision threshold explicitly. Most classifiers output probabilities and default to 0.5, which is almost never the right operating point for skewed data. Plot the precision-recall curve, choose the point that matches your tolerances, and record why you chose it. An auditor at a Canadian bank or a provincial health authority will ask, and "the framework defaulted to it" is not a defence.

For deeper reading, most machine learning textbooks devote only a chapter to imbalance, so supplement them with the imbalanced-learn documentation, which is far more current. A well-regarded machine learning book covers the theory, but the resampling code changes often enough that documentation beats paper. If you are building a deep learning project and want something practical to test your skills on, try classifying rare manufacturing defects from a public image set — it forces you to confront imbalance, augmentation and threshold tuning together.

Watch for pitfalls in computer vision too. If you run OCR machine learning pipelines on scanned Canadian government forms, character classes such as a rarely used diacritic or a faded stamp may be almost absent in your corpus. Adding 200 realistic renderings of those characters often improves results more than any algorithmic tweak.

How This Plays Out Under Canadian Conditions

Language mix matters here. A conversational artificial intelligence assistant built for a Canadian customer service desk must handle French and English and the code-switching between them; rare-language utterances will be a minority class, and an English-dominant training set will quietly under-serve Québec users. Audit performance by language before you audit overall metrics.

Small datasets are another Canadian reality. A regional credit union or municipal transit agency rarely has the volume of a national operator, so imbalance compounds scarcity. In those cases, prefer interpretable models with class weighting over deep networks that need more minority examples than you can supply, and treat aggressive synthetic generation as a last resort.

Finally, document your handling of imbalance in the model card. Privacy law and emerging AI guidance in Canada expect you to explain how a system treats groups that appear rarely in your data. Recording your sampling choices, your threshold rationale and your holdout results turns a technical detail into a defensible record — and gives the next data scientist something better than a 94 percent accuracy figure to work from.

Further Reading