Skip to content

Commit 569697e

Browse files
committed
got plots to programmatically generate higher res versions for pdf.
1 parent 0622fa0 commit 569697e

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

classification1.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ Based on $K=5$ nearest neighbors with these three predictors we would classify t
569569
Figure \@ref(fig:05-more) shows what the data look like when we visualize them
570570
as a 3-dimensional scatter with lines from the new observation to its five nearest neighbors.
571571

572-
```{r 05-more, echo = FALSE, message = FALSE, fig.cap = "3D scatter plot of the standardized symmetry, concavity, and perimeter variables. Note that in general we recommend against using 3D visualizations; here we show the data in 3D only to illustrate what higher dimensions and nearest neighbors look like, for learning purposes.", fig.retina=2, out.width="80%"}
572+
```{r 05-more, echo = FALSE, message = FALSE, fig.cap = "3D scatter plot of the standardized symmetry, concavity, and perimeter variables. Note that in general we recommend against using 3D visualizations; here we show the data in 3D only to illustrate what higher dimensions and nearest neighbors look like, for learning purposes.", fig.retina=2, out.width="100%"}
573573
attrs <- c("Perimeter", "Concavity", "Symmetry")
574574
575575
# create new scaled obs and get NNs

regression1.Rmd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ Figure \@ref(fig:07-knn-mult-viz) visualizes the model's predictions overlaid on
760760
time the predictions are a surface in 3D space, instead of a line in 2D space, as we have 2
761761
predictors instead of 1.
762762

763-
```{r 07-knn-mult-viz, echo = FALSE, message = FALSE, warning = FALSE, fig.cap = "KNN regression model’s predictions represented as a surface in 3D space overlaid on top of the data using three predictors (price, house size, and the number of bedrooms). Note that in general we recommend against using 3D visualizations; here we use a 3D visualization only to illustrate what the surface of predictions looks like for learning purposes.", out.width="80%"}
763+
```{r 07-knn-mult-viz, echo = FALSE, message = FALSE, warning = FALSE, fig.cap = "KNN regression model’s predictions represented as a surface in 3D space overlaid on top of the data using three predictors (price, house size, and the number of bedrooms). Note that in general we recommend against using 3D visualizations; here we use a 3D visualization only to illustrate what the surface of predictions looks like for learning purposes.", out.width="100%"}
764764
xvals <- seq(from = min(sacramento_train$sqft),
765765
to = max(sacramento_train$sqft),
766766
length = 50)
@@ -781,12 +781,12 @@ plot_3d <- plot_ly() |>
781781
x = ~sqft,
782782
y = ~beds,
783783
z = ~price,
784-
marker = list(size = 5, opacity = 0.4, color = "red")
784+
marker = list(size = 2, opacity = 0.4, color = "red")
785785
) |>
786786
layout(scene = list(
787-
xaxis = list(title = "House size (square feet)"),
787+
xaxis = list(title = "Size (sq ft)"),
788788
zaxis = list(title = "Price (USD)"),
789-
yaxis = list(title = "Number of bedrooms")
789+
yaxis = list(title = "Bedrooms")
790790
)) |>
791791
add_surface(
792792
x = ~xvals,
@@ -798,8 +798,8 @@ plot_3d <- plot_ly() |>
798798
if(!is_latex_output()){
799799
plot_3d
800800
} else {
801-
scene = list(camera = list(eye = list(x=2, y=2, z = 1.5)))
802-
plot_3d <- plot_3d %>% layout(scene = scene)
801+
scene = list(camera = list(eye = list(x = -2.1, y = -2.2, z = 0.75)))
802+
plot_3d <- plot_3d |> layout(scene = scene)
803803
save_image(plot_3d, "img/plot3d_knn_regression.png", scale = 10)
804804
knitr::include_graphics("img/plot3d_knn_regression.png")
805805
}

regression2.Rmd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ is `r format(round(lm_mult_test_results %>% filter(.metric == 'rmse') %>% pull(.
454454
In the case of two predictors, we can plot the predictions made by our linear regression creates a *plane* of best fit, as
455455
shown in Figure \@ref(fig:08-3DlinReg).
456456

457-
```{r 08-3DlinReg, echo = FALSE, message = FALSE, warning = FALSE, fig.cap = "Linear regression plane of best fit overlaid on top of the data (using price, house size, and number of bedrooms as predictors). Note that in general we recommend against using 3D visualizations; here we use a 3D visualization only to illustrate what the regression plane looks like for learning purposes.", out.width="80%"}
457+
```{r 08-3DlinReg, echo = FALSE, message = FALSE, warning = FALSE, fig.cap = "Linear regression plane of best fit overlaid on top of the data (using price, house size, and number of bedrooms as predictors). Note that in general we recommend against using 3D visualizations; here we use a 3D visualization only to illustrate what the regression plane looks like for learning purposes.", out.width="100%"}
458458
xvals <- seq(from = min(sacramento_train$sqft),
459459
to = max(sacramento_train$sqft),
460460
length = 50)
@@ -475,12 +475,12 @@ plot_3d <- plot_ly() |>
475475
x = ~sqft,
476476
y = ~beds,
477477
z = ~price,
478-
marker = list(size = 5, opacity = 0.4, color = "red")
478+
marker = list(size = 2, opacity = 0.4, color = "red")
479479
) |>
480480
layout(scene = list(
481-
xaxis = list(title = "House size (square feet)"),
481+
xaxis = list(title = "Size (sq ft)"),
482482
zaxis = list(title = "Price (USD)"),
483-
yaxis = list(title = "Number of bedrooms")
483+
yaxis = list(title = "Bedrooms")
484484
)) |>
485485
add_surface(
486486
x = ~xvals,
@@ -492,7 +492,7 @@ plot_3d <- plot_ly() |>
492492
if(!is_latex_output()){
493493
plot_3d
494494
} else {
495-
scene = list(camera = list(eye = list(x=2, y=2, z = 1.5)))
495+
scene = list(camera = list(eye = list(x = -2.1, y = -2.2, z = 0.75)))
496496
plot_3d <- plot_3d %>% layout(scene = scene)
497497
save_image(plot_3d, "img/plot3d_linear_regression.png", scale = 10)
498498
knitr::include_graphics("img/plot3d_linear_regression.png")

0 commit comments

Comments
 (0)