AWS Builder Center
A Good Score Is Not the Same as a Good Model

A Good Score Is Not the Same as a Good Model

An AWS-grounded look at the accuracy trap in fraud detection: how class imbalance shapes what a model learns, and what an evaluation workflow on SageMaker actually looks like.

Data Engineer Trainee and Student Builder Group Leader
I'm studying for the AWS Certified AI Practitioner exam right now, and most of what I'm learning is exactly what you'd expect from a certification: definitions, service names, the kind of thing you drill until it sticks. But every so often something in the material stops being a fact you memorize and turns into a fact you can't stop thinking about. For me that happened with a single number in the section on evaluation metrics.
If 0.2% of transactions in a dataset are fraudulent, a model that predicts every single transaction as legitimate is 99.8% accurate. It also catches zero fraud. It is, by the one metric most people reach for first, an excellent model. It is also completely useless for the job it was built to do.
I understood the mechanism immediately. What kept me thinking about it afterward was something else: how easily that number could have ended up in a slide deck. Ninety-nine point eight percent accuracy sounds like a result. It would survive a casual review. It might even survive a not-so-casual one, if nobody asked what the model actually predicted.
That's the part that stuck with me. Not the math, which is simple once you see it, but how quiet the failure is. Nothing about a 99.8% accuracy score waves a flag. You have to know to ask what the model is doing with the 0.2%.

Why imbalance changes what a model is actually learning

Class imbalance means the categories you're trying to predict aren't represented evenly in the data. Fraud versus legitimate transactions. Failure versus normal operation. Defective versus acceptable. In most of the situations where this matters, the rare class isn't just smaller. It's the reason the model exists.
Nobody builds a fraud detection system to identify legitimate transactions. Nobody builds a predictive maintenance model to confirm that equipment is fine. The whole point sits inside the sliver of data that's hardest to learn from, because there's so little of it and because the patterns inside it are often inconsistent. Fraud doesn't look like one thing. Neither does equipment failure. The majority class, meanwhile, is abundant and comparatively boring, which is exactly why a model under no particular pressure will gravitate toward predicting it.
This is where I think the standard framing of the accuracy trap undersells the problem a little. It's not just that accuracy is a misleading metric on imbalanced data. It's that the imbalance itself pulls the model toward ignoring the thing you asked it to find, because ignoring it is statistically rewarded. A model trained to minimize overall error will discover, correctly, that predicting the majority class almost every time minimizes overall error. It hasn't failed at the task you described to it. It's succeeded at the task the loss function actually described.

Two kinds of wrong, and they don't cost the same

Once you accept that the rare class is the point, the next question is what happens when the model gets it wrong, and there are two different ways to be wrong here.
A false negative means the model missed something real. Fraud went through. A failure wasn't predicted. A defect passed inspection. A threat wasn't flagged. In each of these, the cost shows up after the fact, sometimes much later, and it can be severe. A missed defect becomes a recall. A missed threat becomes a breach. These are the errors that tend to dominate the conversation when people first learn about imbalanced classification, because they're the ones that make the six o'clock news.
A false positive means the model raised an alarm about something that was fine. A legitimate payment gets blocked. A valid email gets marked as phishing. A customer who wasn't going to leave gets sent a retention discount they didn't need. These sound smaller individually, and often they are. But false positives have a way of accumulating into an operational problem of their own. A security team drowning in low-quality alerts starts ignoring alerts, including eventually the real ones. A payments system that blocks too many legitimate purchases loses customers who get tired of being treated as suspects. The cost isn't one bad decision. It's the slow erosion of trust in the system, by the people who are supposed to be relying on it.
Fraud detection is the clearest example I've found where both of these are expensive at the same time, which is probably why it shows up in so much of the material I've been reading. If you tune a fraud model to catch more fraud, you will, as a near-mechanical consequence, block more legitimate transactions along the way. If you tune it to reduce that friction, you will let more fraud through. There isn't a setting where both numbers improve together. You're choosing a point on a curve, and the curve doesn't have a correct answer sitting on it waiting to be found. The correct answer depends on what a missed fraud costs your business, what a blocked legitimate transaction costs you, and what actually happens downstream when the model flags something. Does a flag mean an automatic decline, or a manual review, or a text message asking the customer to confirm? Those are wildly different costs attached to the same prediction.
I think this is the sentence that best captures what changed for me while studying this: the metric doesn't tell you what a mistake costs. You have to bring that information in from outside the model, and it usually lives in finance, in operations, in customer support, somewhere that isn't the notebook where the model was trained.

What teams actually do about it

The instinct, once you've seen the accuracy trap, is to reach for the dataset and fix the imbalance directly. Oversample the rare class. Undersample the majority. Get the numbers even and assume the problem is solved.
I want to push back gently on the word "solved" here, because a mathematically balanced dataset is not automatically a better business system, and the fixes at the data level come with their own costs.
Oversampling, including synthetic methods that generate new minority-class examples from the patterns in existing ones, can help a model see more of the rare class during training. It can also cause the model to overfit to whatever specific quirks happened to be in that small original sample, especially if the synthetic examples don't reflect how real fraud or real failures actually vary. Undersampling the majority class throws away data, and if that data contained information the model needed, you've traded one problem for another.
Beyond the dataset itself, a few other levers tend to matter more than people expect going in:
Class weights and sample weights let you tell the training algorithm directly that mistakes on the minority class should count for more, without changing what data it sees. This often does more useful work than resampling, because it doesn't distort the underlying data distribution.
The choice of metric matters as much as anything else on this list. Optimizing for accuracy on an imbalanced problem is close to a category error. Precision, recall, F1, balanced accuracy, and the area under a precision-recall curve all give you a more honest picture, and which one you should be watching depends entirely on which kind of mistake worries you more.
The classification threshold is worth more attention than it usually gets. A lot of models don't output "fraud" or "not fraud." They output a score, and someone decides where on that score the label flips. Moving that threshold up or down changes your precision and recall without retraining anything, which makes it one of the cheapest and most direct ways to express your actual risk tolerance.
And maybe the most underused idea in this list: not every prediction needs to collapse into a yes-or-no decision. A fraud score is only useful once someone decides what should happen at each level of risk. A low score might mean nothing happens. A medium score might mean a text message to the customer. A high score might mean the transaction is held for review. You can build very different systems out of the same underlying model just by changing what happens at each threshold, and that design work matters as much as the model itself.

Where AWS fits into this, and where it doesn't

None of what I've described above requires AWS specifically, but studying for this exam has made me think about how a workflow like this could actually be built, and it's worth walking through, mostly because it clarifies where the tooling ends and the judgment begins.
You'd probably start by understanding your data before touching a model at all.  Amazon Athena  lets you query data sitting in  Amazon S3  to see the actual class distribution, and whether it's shifted over time.  AWS Glue  can catalog and prepare that data at scale if it's coming from multiple sources. This step matters more than it sounds like it should, because a lot of imbalance surprises come from discovering that the rare class isn't just small, it's inconsistently labeled, or it's changed shape since the training data was collected.
From there,  Amazon SageMaker Data Wrangler  is worth knowing about specifically here, because its built-in data quality reports flag class imbalance directly as one of the anomalies it looks for, alongside things like missing values and outliers. It won't decide what to do about the imbalance, but it will put the problem in front of you early, which is more than a lot of workflows manage.
Training happens in  Amazon SageMaker AI , where you'd configure class weights or sample weights as part of the training job, or choose an algorithm that handles imbalance natively.  Amazon SageMaker Pipelines  is where I'd want the whole thing to live once it's past the exploratory stage, because it makes preprocessing, training, and evaluation into a single repeatable workflow rather than something rebuilt from memory every time the data shifts. Given how much of this problem depends on getting the same distribution checks run consistently over time, that repeatability isn't a nice-to-have.
At evaluation time, the discipline is to look at precision, recall, F1, balanced accuracy, and precision-recall curves before accuracy gets anywhere near a decision. And the threshold itself deserves to be treated as part of the deployed system, documented and chosen deliberately, not left at whatever default the library shipped with.
After deployment,  Amazon CloudWatch  can track prediction rates, how often cases get flagged for review, how much of a burden that puts on the people doing the reviewing, and whether the labels needed to check the model's actual performance are arriving on any kind of reasonable delay. That last part is easy to overlook. In fraud, you often don't know if a transaction was really fraudulent until weeks after the model made its prediction, which means your ability to measure real-world recall lags behind your ability to measure it in training by however long that confirmation takes.
I want to be direct about what all of this tooling actually does, because it would be easy to read a list like this and think AWS is solving the hard part. It isn't. AWS gives you a way to build, evaluate, deploy, and monitor a system, efficiently and at scale. It does not decide how many false negatives you can tolerate, or what a false positive costs your specific customers, or where the threshold should sit for your specific business. That's a judgment call, made by people who understand the consequences on both sides, and no service does that work for you.

What I'd actually want to know before calling one of these successful

I'm not in a position to claim I'd get this right in practice. I haven't operated one of these systems under real pressure, with real customers on the other end of the false positives. But studying this closely enough to write about it has left me with a rough list of questions I'd want answered before I trusted a claim that an imbalanced model was working.
What does the rare class actually look like, and how much does it vary? A single aggregate recall number can hide the fact that a model catches one common pattern of fraud very well and misses three rarer ones entirely.
What does each kind of mistake cost, in terms someone outside the model team would recognize? Not "the recall is 0.81." What a missed case costs, and what an unnecessary flag costs, in money or time or trust.
Does the training distribution match what the model will actually see in production, and how is that being checked on an ongoing basis rather than once at launch?
And what happens after the prediction. Not the score itself, but the actual decision downstream of it, and whether that decision matches the confidence the score deserves.
None of that is a technical evaluation of a model in the narrow sense. Most of it is a conversation with people who aren't in the room when the model is being trained. I think that's the actual lesson underneath the accuracy trap. The trap isn't really about accuracy being a bad metric. It's about how easy it is to evaluate a model entirely inside the notebook, and how much of what determines whether it's a good decision happens outside it.



4. Fact-check note

Principal AWS sources used:
  •  Amazon SageMaker Data Wrangler product page  — confirmed it is current, actively documented, and that its data quality and insights report explicitly detects class imbalance as one of its flagged anomalies (alongside outliers and data leakage). This was a genuinely useful find and is the one specific product claim in the article worth double-checking closest to publication, since Data Wrangler has had a somewhat complicated product history (it originated as a Studio Classic feature).
  •  SageMaker Pipelines documentation  — confirmed current, including its role in orchestrating Processing, Training, and Inference steps with built-in versioning and lineage tracking.
  • Amazon Athena, AWS Glue, Amazon S3, Amazon SageMaker AI, Amazon CloudWatch — all long-standing, stable services; no naming or availability concerns.
Should be reverified before publication:
  • The exact current phrasing and scope of the SageMaker Data Wrangler "data quality and insights report" feature, since SageMaker's Studio surfaces have been reorganized more than once (Studio Classic vs. SageMaker Unified Studio), and the article references it fairly specifically.
  • Whether "SageMaker Processing" should be referred to by that exact name or folded into more general "SageMaker AI" language in current AWS materials — I saw it used both ways in recent documentation and defaulted to mentioning SageMaker AI as the umbrella and Pipelines/Data Wrangler as the specific named capabilities, to stay safely current.
  • No specific customer results, benchmark numbers, or unverified statistics were included anywhere in the article. The only numeric example (0.2% fraud rate, 99.8% accuracy) is illustrative arithmetic, consistent with how it's used in AWS's own certification materials, not a cited real-world statistic.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article