Skip to content

Commit 1bc75ba

Browse files
committed
Line edits
1 parent aa1f3ba commit 1bc75ba

File tree

7 files changed

+21
-13
lines changed

7 files changed

+21
-13
lines changed

learn-pr/azure/optimize-model-performance-roc-auc/8-knowledge-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ quiz:
3838
choices:
3939
- content: "How well the model works at its optimum decision threshold"
4040
isCorrect: false
41-
explanation: "Incorrect. This information might be obtainable from the ROC plot but we can't get this information from the AUC."
41+
explanation: "Incorrect. This information might be obtainable from the ROC plot, but we can't get this information from the AUC."
4242
- content: "Which is the optimum decision threshold?"
4343
isCorrect: false
4444
explanation: "Incorrect. AUC is a summary metric that is too simplified to provide this information."

learn-pr/azure/optimize-model-performance-roc-auc/includes/1-introduction.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
We can assess our classification models in terms of the kinds of mistakes that they make, such as false negatives and false positives. This can give insight into the kinds of mistakes a model makes, but doesn't necessarily provide deep information on how the model could perform if slight adjustments were made to its decision criteria. Here, we'll discuss receiver operator characteristic (ROC) curves, which build on the idea of a confusion matrix but provide us with deeper information that lets us improve our models to a greater degree.
1+
We can assess our classification models in terms of the kinds of mistakes that they make, such as false negatives and false positives. This can give insight into the kinds of mistakes a model makes, but it doesn't necessarily provide deep information on how the model could perform if slight adjustments were made to its decision criteria. Here, we'll discuss receiver operator characteristic curves. ROC curves build on the idea of a confusion matrix but provide us with deeper information that lets us improve our models to a greater degree.
22

3-
## Scenario:
3+
## Scenario
44

5-
Throughout this module, well be using the following example scenario to explain and practice working with ROC curves.
5+
Throughout this module, we'll be using the following example scenario to explain and practice working with ROC curves.
66

77
Your avalanche-rescue charity has successfully built a machine learning model that can estimate whether an object detected by lightweight sensors is a hiker or a natural object, such as a tree or a rock. This lets you keep track of how many people are on the mountain, so you know whether a rescue team is needed when an avalanche strikes. The model does reasonably well, though you wonder if there's room for improvement. Internally, the model must make a binary decision as to whether an object is a hiker or not, but this is based on probabilities. Can this decision-making process be tweaked to improve its performance?
88

learn-pr/azure/optimize-model-performance-roc-auc/includes/2-receiver-operator-characteristic-curve.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ We can calculate some handy characteristics from the confusion matrix. Two popul
2323

2424
Looking at true positive and false positive rates can help us understand a model's performance.
2525

26-
Consider our hiker example. Ideally, the true positive rate is very high, and the false positive rate is very low, because this means that the model identifies hikers well and doesn't identify trees as hikers very often. Yet, if the true positive rate is very high, but the false positive rate is also very high, then the model is biased; it's identifying almost everything it encounters as hiker. Similarly, we don't want a model with a low true positive rate, because then when the model encounters a hiker, it'll label them as a tree.
26+
Consider our hiker example. Ideally, the true positive rate is very high, and the false positive rate is very low. This means that the model identifies hikers well and doesn't identify trees as hikers very often. Yet, if the true positive rate is very high, but the false positive rate is also very high, then the model is biased; it's identifying almost everything it encounters as hiker. Similarly, we don't want a model with a low true positive rate, because then when the model encounters a hiker, it'll label them as a tree.
2727

2828
## ROC curves
2929

30-
Receiver operator characteristic (ROC) curves are a graph where we plot true positive rate versus false positive rate.
30+
Receiver operator characteristic curves are a graph where we plot true positive rate versus false positive rate.
3131

3232
ROC curves can be confusing for beginners for two main reasons. The first reason is that beginners know that a model only has one value for true positive and true negative rates, so an ROC plot must look like this:
3333

3434
![Receiver operator characteristic curve graph with one plot point.](../media/roc-graph.png)
3535

36-
If you're also thinking this, you're right. A trained model only produces one point. However, remember that our models have a thresholdnormally 50%that's used to decide whether the true (hiker) or false (tree) label should be used. If we change this threshold to 30% and recalculate true positive and false positive rates, we get another point:
36+
If you're also thinking this, you're right. A trained model only produces one point. However, remember that our models have a threshold-normally 50%-that's used to decide whether the true (hiker) or false (tree) label should be used. If we change this threshold to 30% and recalculate true positive and false positive rates, we get another point:
3737

3838
![Receiver operator characteristic curve graph with two plot points.](../media/roc-graph-2.png)
3939

learn-pr/azure/optimize-model-performance-roc-auc/includes/4-compare-optimize-curves.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
Receiver operator characteristic (ROC) curves let us compare models to one another and tune our selected model. Let's discuss how and why these are done.
1+
ROC curves let us compare models to one another and tune our selected model. Let's discuss how and why these are done.
22

33
## Tuning a model
44

55
The most obvious use for an ROC curve is to choose a decision threshold that gives the best performance. Recall that our models provide us with probabilities, such as a 65% chance that the sample is a hiker. The decision threshold is the point above which a sample is assigned true (hiker) or below which it's assigned `false` (tree). If our decision threshold was 50%, then 65% would be assigned to "true" (hiker). If our decision threshold was 70%, however, a probability of 65% would be too small, and be assigned to "false" (tree).
66

77
We've seen in the previous exercise that when we construct an ROC curve, we're just changing the decision threshold and assessing how well the model works. When we do this, we can find the threshold that gives the optimal results.
88

9-
Usually there isn't a single threshold that gives both the best true positive rate (TPR) and the lower false positive rate (FPR). This means that the optimal threshold depends on what you're trying to achieve. For example, in our scenario, it's very important to have a high true positive rate, because if a hiker isn't identified and an avalanche occurs, the team won't know to rescue them. There's a trade-off, though: if the false positive rate is too high, then the rescue team may repeatedly be sent out to rescue people who simply don't exist. In other situations, the false positive rate is considered more important. For example, science has a low tolerance for false-positive results. If the false-positive rate of scientific experiments was higher, there would be an endless flurry of contradictory claims, and it would be impossible to make sense of what's real.
9+
Usually there isn't a single threshold that gives both the best true positive rate (TPR) and the lower false positive rate (FPR). This means that the optimal threshold depends on what you're trying to achieve. For example, in our scenario, it's very important to have a high true positive rate. This is because if a hiker isn't identified and an avalanche occurs, the team won't know to rescue them. There's a trade-off, though: if the false positive rate is too high, then the rescue team may repeatedly be sent out to rescue people who simply don't exist. In other situations, the false positive rate is considered more important. For example, science has a low tolerance for false-positive results. If the false-positive rate of scientific experiments was higher, there would be an endless flurry of contradictory claims, and it would be impossible to make sense of what's real.
1010

1111
## Comparing models with AUC
1212

1313
You can use ROC curves to compare models to each other, just like you can with cost functions. An ROC curve for a model shows how well it will work for a variety of decision thresholds. At the end of the day, what's most important in a model is how it will perform in the real world, where there's only one decision threshold. Why then would we want to compare models using thresholds we'll never use? There are two answers for this.
1414

1515
Firstly, comparing ROC curves in particular ways is like performing a statistical test that tells us not just that one model did better on this particular test set, but whether it's likely to continue to perform better in the future. This is out of the scope of this learning material, but it's worth keeping in mind.
1616

17-
Secondly, the ROC curve shows, to some degree, how reliant the model is on having the perfect threshold. For example, if our model only works well when we have a decision threshold of 0.9, but terribly above or below this value, it's not a good design. We'd probably prefer to work with a model that works reasonably well for various thresholds, knowing that if the real-world data we come across is slightly different to our test set, our model's performance won't necessarily collapse.
17+
Secondly, the ROC curve shows, to some degree, how reliant the model is on having the perfect threshold. For example, if our model only works well when we have a decision threshold of 0.9, but terribly above or below this value, it's not a good design. We'd probably prefer to work with a model that works reasonably well for various thresholds. We'd know that if the real-world data we come across is slightly different to our test set, our model's performance won't necessarily collapse.
1818

1919
### How to compare ROCs?
2020

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
We've covered receiver operator characteristic (ROC) curves in some depth. We learned they graph how often we mistakenly assign a true label against how often we correctly assign a true label. Each point on the graph represents one threshold that was applied.
1+
We've covered ROC curves in some depth. We learned they graph how often we mistakenly assign a true label against how often we correctly assign a true label. Each point on the graph represents one threshold that was applied.
2+
3+
We learned how we can use ROC curves to tune our decision threshold in the final model. We also saw how AUC can give us an idea as to how reliant our model is to having the perfect decision threshold. It's also a handy measure to compare two models to one another.
24

3-
We learned how we can use ROC curves to tune our decision threshold in the final model. We also saw how area-under the curve (AUC) can give us an idea as to how reliant our model is to having the perfect decision threshold. It's also a handy measure to compare two models to one another.
45
Congratulations on getting so far! As always, now that you have a new technique under your belt, the best you can do for your learning is practice using it on data you care about. By doing so, you'll gain experience and understand nuances that we haven't had time or space to cover here. Good luck!

learn-pr/azure/optimize-model-performance-roc-auc/index.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ metadata:
1212
- TBD
1313
- ce-skilling-ai-copilot
1414
title: Measure and optimize model performance with ROC and AUC
15-
summary: Receiver operator characteristic curves are a powerful way to assess and fine-tune trained classification models. We introduce and explain the utility of these curves through learning content and practical exercises.
15+
summary: Receiver operator characteristic (ROC) curves are a powerful way to assess and fine-tune trained classification models. We introduce and explain the utility of these curves through learning content and practical exercises.
1616
abstract: |
1717
In this module, you will:
1818
- Understand how to create ROC curves.

learn-pr/azure/optimize-model-performance-roc-auc/notebooks/9-3-evaluate-roc-curves.ipynb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,13 @@
382382
"If we continued this approach for all thresholds, we'd achieve a diagonal line."
383383
]
384384
},
385+
{
386+
"cell_type": "code",
387+
"execution_count": null,
388+
"metadata": {},
389+
"outputs": [],
390+
"source": []
391+
},
385392
{
386393
"cell_type": "markdown",
387394
"metadata": {},

0 commit comments

Comments
 (0)