Skip to content

Commit 416209d

Browse files
Merge pull request #284 from UBC-DSCI/truly-actually
Changing "true label" to "actual label"
2 parents cc94406 + 0645a7b commit 416209d

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

source/classification1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ new_obs = pd.DataFrame({"Perimeter": [0], "Concavity": [3.5]})
983983
knn.predict(new_obs)
984984
```
985985

986-
Is this predicted malignant label the true class for this observation?
986+
Is this predicted malignant label the actual class for this observation?
987987
Well, we don't know because we do not have this
988988
observation's diagnosis— that is what we were trying to predict! The
989989
classifier's prediction is not necessarily correct, but in the next chapter, we will

source/classification2.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ tumor images?
6969

7070
The trick is to split the data into a **training set** and **test set** ({numref}`fig:06-training-test`)
7171
and use only the **training set** when building the classifier.
72-
Then, to evaluate the performance of the classifier, we first set aside the true labels from the **test set**,
73-
and then use the classifier to predict the labels in the **test set**. If our predictions match the true
72+
Then, to evaluate the performance of the classifier, we first set aside the labels from the **test set**,
73+
and then use the classifier to predict the labels in the **test set**. If our predictions match the actual
7474
labels for the observations in the **test set**, then we have some
7575
confidence that our classifier might also accurately predict the class
7676
labels for new observations without known class labels.
@@ -102,12 +102,12 @@ Splitting the data into training and testing sets.
102102
```{index} accuracy
103103
```
104104

105-
How exactly can we assess how well our predictions match the true labels for
105+
How exactly can we assess how well our predictions match the actual labels for
106106
the observations in the test set? One way we can do this is to calculate the
107107
prediction **accuracy**. This is the fraction of examples for which the
108108
classifier made the correct prediction. To calculate this, we divide the number
109109
of correct predictions by the number of predictions made.
110-
The process for assessing if our predictions match the true labels in the
110+
The process for assessing if our predictions match the actual labels in the
111111
test set is illustrated in {numref}`fig:06-ML-paradigm-test`.
112112

113113
$$\mathrm{accuracy} = \frac{\mathrm{number \; of \; correct \; predictions}}{\mathrm{total \; number \; of \; predictions}}$$
@@ -139,10 +139,10 @@ a test set of 65 observations.
139139
* -
140140
- Predicted Malignant
141141
- Predicted Benign
142-
* - **Truly Malignant**
142+
* - **Actually Malignant**
143143
- 1
144144
- 3
145-
* - **Truly Benign**
145+
* - **Actually Benign**
146146
- 4
147147
- 57
148148
```
@@ -607,7 +607,7 @@ knn_fit
607607
Now that we have a $K$-nearest neighbors classifier object, we can use it to
608608
predict the class labels for our test set. We will use the `assign` method to
609609
augment the original test data with a column of predictions, creating the
610-
`cancer_test_predictions` data frame. The `Class` variable contains the true
610+
`cancer_test_predictions` data frame. The `Class` variable contains the actual
611611
diagnoses, while the `predicted` contains the predicted diagnoses from the
612612
classifier. Note that below we print out just the `ID`, `Class`, and `predicted`
613613
variables in the output data frame.
@@ -640,9 +640,9 @@ correct_preds.shape[0] / cancer_test_predictions.shape[0]
640640

641641
The `scitkit-learn` package also provides a more convenient way to do this using
642642
the `score` method. To use the `score` method, we need to specify two arguments:
643-
predictors and true labels. We pass the same test data
643+
predictors and the actual labels. We pass the same test data
644644
for the predictors that we originally passed into `predict` when making predictions,
645-
and we provide the true labels via the `cancer_test["Class"]` series.
645+
and we provide the actual labels via the `cancer_test["Class"]` series.
646646

647647
```{code-cell} ipython3
648648
cancer_acc_1 = knn_fit.score(
@@ -664,9 +664,9 @@ The output shows that the estimated accuracy of the classifier on the test data
664664
was {glue:text}`cancer_acc_1`%.
665665
We can also look at the *confusion matrix* for the classifier
666666
using the `crosstab` function from `pandas`. A confusion matrix shows how many
667-
observations of each (true) label were classified as each (predicted) label.
667+
observations of each (actual) label were classified as each (predicted) label.
668668
The `crosstab` function
669-
takes two arguments: the true labels first, then the predicted labels second.
669+
takes two arguments: the actual labels first, then the predicted labels second.
670670

671671
```{code-cell} ipython3
672672
pd.crosstab(
@@ -703,8 +703,8 @@ glue("confu_recall_0", "{:0.0f}".format(100*c11/(c11+c10)))
703703
The confusion matrix shows {glue:text}`confu11` observations were correctly predicted
704704
as malignant, and {glue:text}`confu00` were correctly predicted as benign.
705705
It also shows that the classifier made some mistakes; in particular,
706-
it classified {glue:text}`confu10` observations as benign when they were truly malignant,
707-
and {glue:text}`confu01` observations as malignant when they were truly benign.
706+
it classified {glue:text}`confu10` observations as benign when they were actually malignant,
707+
and {glue:text}`confu01` observations as malignant when they were actually benign.
708708
Using our formulas from earlier, we see that the accuracy agrees with what Python reported,
709709
and can also compute the precision and recall of the classifier:
710710

@@ -758,11 +758,11 @@ of the time, a classifier with 99% accuracy is not terribly impressive (just alw
758758
And beyond just accuracy, we need to consider the precision and recall: as mentioned
759759
earlier, the *kind* of mistake the classifier makes is
760760
important in many applications as well. In the previous example with 99% benign observations, it might be very bad for the
761-
classifier to predict "benign" when the true class is "malignant" (a false negative), as this
761+
classifier to predict "benign" when the actual class is "malignant" (a false negative), as this
762762
might result in a patient not receiving appropriate medical attention. In other
763763
words, in this context, we need the classifier to have a *high recall*. On the
764764
other hand, it might be less bad for the classifier to guess "malignant" when
765-
the true class is "benign" (a false positive), as the patient will then likely see a doctor who
765+
the actual class is "benign" (a false positive), as the patient will then likely see a doctor who
766766
can provide an expert diagnosis. In other words, we are fine with sacrificing
767767
some precision in the interest of achieving high recall. This is why it is
768768
important not only to look at accuracy, but also the confusion matrix.

0 commit comments

Comments
 (0)