Bookdown Demo PDF
Bookdown Demo PDF
Grégoire Virepinte
2018-07-24
2
Contents
Introduction 5
Why this book? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Why write this in English? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
What to find here? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1 Prerequisites 7
2 Model Selection 9
2.1 The Bias-Variance Trade-Off . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Cross-validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3 The use of information criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4 Bootstrap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.5 ROC Curve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3 Regression 11
3.1 Linear regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 Logistic regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.3 Polynomial regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.4 Constraints: Ridge, Lasso, Elastic Net . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.5 Non-linear regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.6 Random and fixed effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4 Missing values 13
5 Gradient boosting 15
5.1 Fundamental idea . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.2 Basic algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.3 An implementation of XGBoost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
6 Random Forest 17
6.1 Idea . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6.2 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3
4 CONTENTS
Introduction
5
6 CONTENTS
Chapter 1
Prerequisites
This is a sample book written in Markdown. You can use anything that Pandoc’s Markdown supports,
e.g., a math equation a2 + b2 = c2 .
The bookdown package can be installed from CRAN or Github:
install.packages("bookdown")
# or the development version
# devtools::install_github("rstudio/bookdown")
Remember each Rmd file contains one and only one chapter, and a chapter is defined by the first-level
heading #.
To compile this example to PDF, you need XeLaTeX. You are recommended to install TinyTeX (which
includes XeLaTeX): https://yihui.name/tinytex/.
7
8 CHAPTER 1. PREREQUISITES
Chapter 2
Model Selection
2.2 Cross-validation
2.4 Bootstrap
Reference a figure by its code chunk label with the fig: prefix, e.g., see Figure 2.1. Similarly, you can
reference tables generated from knitr::kable(), e.g., see Table 2.1.
knitr::kable(
head(iris, 20), caption = 'Here is a nice table!',
booktabs = TRUE
)
You can write citations, too. For example, we are using the bookdown package (Xie, 2018) in this sample
book, which was built on top of R Markdown and knitr (Xie, 2015).
9
10 CHAPTER 2. MODEL SELECTION
800
600
pressure
400
200
0
temperature
Regression
11
12 CHAPTER 3. REGRESSION
Chapter 4
Missing values
13
14 CHAPTER 4. MISSING VALUES
Chapter 5
Gradient boosting
15
16 CHAPTER 5. GRADIENT BOOSTING
Chapter 6
Random Forest
6.1 Idea
6.2 Implementation
17
18 CHAPTER 6. RANDOM FOREST
Bibliography
Xie, Y. (2015). Dynamic Documents with R and knitr. Chapman and Hall/CRC, Boca Raton, Florida, 2nd
edition. ISBN 978-1498716963.
Xie, Y. (2018). bookdown: Authoring Books and Technical Documents with R Markdown. R package version
0.7.
19