Skip to content

Commit 626d180

Browse files
committed
adjusting plot fonts and sizes in classification2
1 parent 7e8f42d commit 626d180

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

classification2.Rmd

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ print_tidymodels <- function(tidymodels_object) {
2626
}
2727
}
2828
29-
theme_update(axis.title = element_text(size = 14)) # modify axis label size in plots
29+
theme_update(axis.title = element_text(size = 12)) # modify axis label size in plots
3030
3131
```
3232

@@ -232,7 +232,7 @@ perim_concav <- cancer |>
232232
labs(color = "Diagnosis") +
233233
scale_color_manual(labels = c("Malignant", "Benign"),
234234
values = c("orange2", "steelblue2")) +
235-
theme(text = element_text(size = 14))
235+
theme(text = element_text(size = 12))
236236
237237
perim_concav
238238
```
@@ -788,7 +788,7 @@ accuracy_vs_k <- ggplot(accuracies, aes(x = neighbors, y = mean)) +
788788
geom_point() +
789789
geom_line() +
790790
labs(x = "Neighbors", y = "Accuracy Estimate") +
791-
theme(text = element_text(size = 14))
791+
theme(text = element_text(size = 12))
792792
793793
accuracy_vs_k
794794
```
@@ -846,7 +846,7 @@ accuracy_vs_k_lots <- ggplot(accuracies, aes(x = neighbors, y = mean)) +
846846
geom_point() +
847847
geom_line() +
848848
labs(x = "Neighbors", y = "Accuracy Estimate") +
849-
theme(text = element_text(size = 14))
849+
theme(text = element_text(size = 12))
850850
851851
accuracy_vs_k_lots
852852
```
@@ -926,7 +926,7 @@ for (i in 1:length(ks)) {
926926
ggtitle(paste("K = ", ks[[i]])) +
927927
scale_color_manual(labels = c("Malignant", "Benign"),
928928
values = c("orange2", "steelblue2")) +
929-
theme(text = element_text(size = 18))
929+
theme(text = element_text(size = 18), axis.title=element_text(size=18))
930930
}
931931
932932
p_no_legend <- lapply(plots, function(x) x + theme(legend.position = "none"))
@@ -1036,7 +1036,7 @@ variables there are, the more (random) influence they have, and the more they
10361036
corrupt the set of nearest neighbors that vote on the class of the new
10371037
observation to predict.
10381038

1039-
```{r 06-performance-irrelevant-features, echo = FALSE, warning = FALSE, fig.retina = 2, out.width = "60%", fig.cap = "Effect of inclusion of irrelevant predictors."}
1039+
```{r 06-performance-irrelevant-features, echo = FALSE, warning = FALSE, fig.retina = 2, out.width = "65%", fig.cap = "Effect of inclusion of irrelevant predictors."}
10401040
# get accuracies after including k irrelevant features
10411041
ks <- c(0, 5, 10, 15, 20, 40)
10421042
fixedaccs <- list()
@@ -1110,7 +1110,7 @@ plt_irrelevant_accuracies <- ggplot(res) +
11101110
geom_line(mapping = aes(x=ks, y=accs)) +
11111111
labs(x = "Number of Irrelevant Predictors",
11121112
y = "Model Accuracy Estimate") +
1113-
theme(text = element_text(size = 18))
1113+
theme(text = element_text(size = 16), axis.title=element_text(size=16))
11141114
11151115
plt_irrelevant_accuracies
11161116
```
@@ -1126,12 +1126,12 @@ variables, the number of neighbors does not increase smoothly; but the general t
11261126
Figure \@ref(fig:06-fixed-irrelevant-features) corroborates
11271127
this evidence; if we fix the number of neighbors to $K=3$, the accuracy falls off more quickly.
11281128

1129-
```{r 06-neighbors-irrelevant-features, echo = FALSE, warning = FALSE, fig.retina = 2, out.width = "60%", fig.cap = "Tuned number of neighbors for varying number of irrelevant predictors."}
1129+
```{r 06-neighbors-irrelevant-features, echo = FALSE, warning = FALSE, fig.retina = 2, out.width = "65%", fig.cap = "Tuned number of neighbors for varying number of irrelevant predictors."}
11301130
plt_irrelevant_nghbrs <- ggplot(res) +
11311131
geom_line(mapping = aes(x=ks, y=nghbrs)) +
11321132
labs(x = "Number of Irrelevant Predictors",
11331133
y = "Number of neighbors") +
1134-
theme(text = element_text(size = 18))
1134+
theme(text = element_text(size = 16), axis.title=element_text(size=16))
11351135
11361136
plt_irrelevant_nghbrs
11371137
```
@@ -1145,7 +1145,7 @@ plt_irrelevant_nghbrs <- ggplot(res_tmp) +
11451145
geom_line(mapping = aes(x=ks, y=accuracy, color=Type)) +
11461146
labs(x = "Number of Irrelevant Predictors", y = "Accuracy") +
11471147
scale_color_discrete(labels= c("Tuned K", "K = 3")) +
1148-
theme(text = element_text(size = 16))
1148+
theme(text = element_text(size = 16), axis.title=element_text(size=16))
11491149
11501150
plt_irrelevant_nghbrs
11511151
```
@@ -1373,12 +1373,12 @@ where the elbow occurs, and whether adding a variable provides a meaningful incr
13731373
> part of tuning your classifier, you *cannot use your test data* for this
13741374
> process!
13751375
1376-
```{r 06-fwdsel-3, echo = FALSE, warning = FALSE, fig.retina = 2, out.width = "60%", fig.cap = "Estimated accuracy versus the number of predictors for the sequence of models built using forward selection."}
1376+
```{r 06-fwdsel-3, echo = FALSE, warning = FALSE, fig.retina = 2, out.width = "65%", fig.cap = "Estimated accuracy versus the number of predictors for the sequence of models built using forward selection."}
13771377
fwd_sel_accuracies_plot <- accuracies |>
13781378
ggplot(aes(x = size, y = accuracy)) +
13791379
geom_line() +
13801380
labs(x = "Number of Predictors", y = "Estimated Accuracy") +
1381-
theme(text = element_text(size = 18))
1381+
theme(text = element_text(size = 18), axis.title=element_text(size=18))
13821382
13831383
fwd_sel_accuracies_plot
13841384
```

0 commit comments

Comments
 (0)