You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (knitr::is_latex_output()) 'latex' else 'pandoc'
13
13
})
14
+
reticulate::use_miniconda('r-reticulate')
14
15
```
15
16
16
17
## Overview
@@ -572,7 +573,7 @@ Based on $K=5$ nearest neighbors with these three predictors we would classify t
572
573
Figure \@ref(fig:05-more) shows what the data look like when we visualize them
573
574
as a 3-dimensional scatter with lines from the new observation to its five nearest neighbors.
574
575
575
-
```{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%"}
576
+
```{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%"}
576
577
attrs <- c("Perimeter", "Concavity", "Symmetry")
577
578
578
579
# create new scaled obs and get NNs
@@ -602,7 +603,7 @@ plot_3d <- scaled_cancer_3 |>
602
603
z = ~Symmetry,
603
604
color = ~Class,
604
605
opacity = 0.4,
605
-
size = 150,
606
+
size = 2,
606
607
colors = c("orange2", "steelblue2", "red"),
607
608
symbol = ~Class, symbols = c('circle','circle','diamond'))
608
609
@@ -641,6 +642,11 @@ plot_3d <- plot_3d %>%
641
642
if(!is_latex_output()){
642
643
plot_3d
643
644
} else {
645
+
# scene = list(camera = list(eye = list(x=2, y=2, z = 1.5)))
Copy file name to clipboardExpand all lines: regression1.Rmd
+8-4Lines changed: 8 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ library(knitr)
5
5
library(plotly)
6
6
7
7
knitr::opts_chunk$set(fig.align = "center")
8
+
reticulate::use_miniconda('r-reticulate')
8
9
```
9
10
10
11
## Overview
@@ -759,7 +760,7 @@ Figure \@ref(fig:07-knn-mult-viz) visualizes the model's predictions overlaid on
759
760
time the predictions are a surface in 3D space, instead of a line in 2D space, as we have 2
760
761
predictors instead of 1.
761
762
762
-
```{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%"}
In the case of two predictors, we can plot the predictions made by our linear regression creates a *plane* of best fit, as
454
455
shown in Figure \@ref(fig:08-3DlinReg).
455
456
456
-
```{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%"}
Copy file name to clipboardExpand all lines: version-control.Rmd
+92-26Lines changed: 92 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -468,6 +468,7 @@ version control: you won't be able to see, interpret, or find changes in the his
468
468
of any of the actual content of your project!
469
469
470
470
## Working with local repositories using Jupyter {#local-repo-jupyter}
471
+
471
472
Although there are several ways to create and edit files on GitHub, they are
472
473
not quite powerful enough for efficiently creating and editing complex files,
473
474
or files that need to be executed to assess whether they work (e.g., files
@@ -477,14 +478,76 @@ remote repository that was created on GitHub to a local coding environment. Thi
477
478
can be done by creating and working in a local copy of the repository.
478
479
In this chapter, we focus on interacting with Git via Jupyter using
479
480
the Jupyter Git extension. The Jupyter Git \index{git!Jupyter extension} extension
480
-
can be run via Jupyter on your local computer, or on a JupyterHub server.
481
+
can be run by Jupyter on your local computer, or on a JupyterHub server.
481
482
*Note: we recommend reading Chapter \@ref(getting-started-with-jupyter)*
482
483
*to learn how to use Jupyter before reading this chapter.*
483
484
485
+
### Generating a GitHub personal access token
486
+
487
+
To send and retrieve work between your local repository
488
+
and the remote repository on GitHub,
489
+
you will frequently need to authenticate with GitHub
490
+
to prove you have the required permission.
491
+
There are several methods to do this,
492
+
but for beginners we recommend using the HTTPS method
493
+
because it is easier and requires less setup.
494
+
In order to use the HTTPS method,
495
+
GitHub requires you to provide a *personal access token*. \index{GitHub!personal access token}
496
+
A personal access token is like a password—so keep it a secret!—but it gives
497
+
you more fine-grained control over what parts of your account
498
+
the token can be used to access, and lets you set an expiry date for the authentication.
499
+
To generate a personal access token,
500
+
you must first visit [https://github.com/settings/tokens](https://github.com/settings/tokens),
501
+
which will take you to the "Personal access tokens" page in your account settings.
502
+
Once there, click "Generate new token" (Figure \@ref(fig:generate-pat-01)).
503
+
Note that you may be asked to re-authenticate with your username
504
+
and password to proceed.
505
+
506
+
(ref:generate-pat-01) The "Generate new token" button used to initiate the creation of a new personal access token. It is found in the "Personal access tokens" section of the "Developer settings" page in your account settings.
To send the committed changes back to the remote repository on
596
-
GitHub, we need to *push* them. \index{git!push} To do this we click on the cloud icon with the up arrow on the Jupyter Git tab
659
+
GitHub, you need to *push* them. \index{git!push} To do this,
660
+
click on the cloud icon with the up arrow on the Jupyter Git tab
597
661
(Figure \@ref(fig:git-push-01)).
598
662
599
663
(ref:git-push-01) The Jupyter Git extension "push" button (circled in red).
@@ -602,23 +666,25 @@ GitHub, we need to *push* them. \index{git!push} To do this we click on the clou
602
666
image_read("img/version_control/git_push_01.png")
603
667
```
604
668
605
-
We will then be prompted to enter our GitHub username
606
-
and password, and click the blue "OK" button (Figure \@ref(fig:git-push-02)).
669
+
You will then be prompted to enter your GitHub username
670
+
and the personal access token that you generated
671
+
earlier (not your account password!). Click
672
+
the blue "OK" button to initiate the push (Figure \@ref(fig:git-push-02)).
607
673
608
674
```{r git-push-02, fig.cap = 'Enter your Git credentials to authorize the push to the remote repository.', fig.retina = 2, out.width="100%"}
609
675
image_read("img/version_control/git_push_02.png")
610
676
```
611
677
612
-
If the files were successfully pushed to our project repository on
613
-
GitHub we will be given the success message shown below.
614
-
Click "Dismiss" to continue working in Jupyter (Figure \@ref(fig:git-push-03)).
678
+
If the files were successfully pushed to the project repository on
679
+
GitHub, you will be shown a success message (Figure \@ref(fig:git-push-03)).
680
+
Click "Dismiss" to continue working in Jupyter.
615
681
616
682
```{r git-push-03, fig.cap = 'The prompt that the push was successful.', fig.retina = 2, out.width="100%"}
617
683
image_read("img/version_control/git_push_03.png")
618
684
```
619
685
620
686
If you visit the remote repository on GitHub,
621
-
you will see that the changes now exist there via their web interface
687
+
you will see that the changes now exist there too
622
688
(Figure \@ref(fig:git-push-04))!
623
689
624
690
```{r git-push-04, fig.cap = 'The GitHub web interface shows a preview of the commit message, and the time of the most recently pushed commit for each file.', fig.retina = 2, out.width="100%"}
To fix the merge conflict, \index{git!merge conflict} we need to open the offending file
825
+
To fix the merge conflict, \index{git!merge conflict} you need to open the offending file
760
826
in a plain text editor and look for special marks that Git puts in the file to
761
827
tell you where the merge conflict occurred (Figure \@ref(fig:merge-conflict-04)).
762
828
@@ -865,7 +931,7 @@ Now that you've picked up the basics of version control with Git and GitHub,
865
931
you can expand your knowledge through the resources listed below:
866
932
867
933
- GitHub's [guides website](https://guides.github.com/) and [YouTube channel](https://www.youtube.com/githubguides),
868
-
and [Happy Git](https://happygitwithr.com/) are great resources to take the next steps in learning about Git and GitHub.
934
+
and [*Happy Git with R*](https://happygitwithr.com/) are great resources to take the next steps in learning about Git and GitHub.
869
935
-[Good enough practices in scientific computing](https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1005510#sec014)[-@wilson2014best] provides more advice on useful workflows and "good enough" practices in data analysis projects.
870
936
- In addition to [GitHub](https://github.com), there are other popular Git repository hosting services such as [GitLab](https://gitlab.com) and [BitBucket](https://bitbucket.org). Comparing all of these options is beyond the scope of this book, and until you become a more advanced user you are perfectly fine to just stick with GitHub. Just be aware that you have options!
871
-
937
+
-[GitHub's documentation on creating a personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) and the *Happy Git with R*[cache credentials for HTTPS](https://happygitwithr.com/credential-caching.html) chapter are both excellent additional resources to consult if you need additional help generating and using personal access tokens.
0 commit comments