This repository has been archived by the owner on Aug 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMovieLens.rmd
executable file
·162 lines (128 loc) · 3.41 KB
/
MovieLens.rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
---
title: "HarvardX - PH125.9x Data Science: Capstone - Movie Lens"
subtitle: "HarvardX - PH125.9x Data Science Capstone"
author: "Emmanuel Rialland - https://github.com/Emmanuel_R8"
date: "`r format(Sys.time(), '%B %d, %Y')`"
site: bookdown::bookdown_site
output:
bookdown::pdf_book:
toc: true
toc_depth: 3
number_sections: true
keep_tex: true
df_print: kable
html_document:
number_sections: true
df_print: paged
theme: united
documentclass: report
geometry: "a4paper,left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm"
lot: yes
lof: yes
fontsize: 11pt
mainfont: "Lato"
monofont: "Hack"
monofontoptions: "Scale=0.7"
bibliography: [packages.bib, bibliography.bib]
biblio-style: apalike
link-citations: yes
colorlinks: yes
github-repo: Emmanuel_R8/HarvardX-Movielens
description: "HarvardX - PH125.9x Data Science Capstone"
---
```{r,echo=FALSE,message=FALSE}
###################################################################################################
## GLOBAL SETUP
##
# Trigger line numbering
knitr::opts_chunk$set(
class.source = "numberLines lineAnchors",
class.output = c("numberLines lineAnchors chunkout")
)
# knitr global settings - By default, the final document will not include source code unless
# expressly stated.
knitr::opts_chunk$set(
# Chunks
eval = TRUE,
cache = TRUE,
echo = FALSE,
message = FALSE,
warning = FALSE,
# filepaths
fig.path = 'build/figure/graphics-',
cache.path = 'build/cache/graphics-',
# Graphics
out.width = "70%",
fig.align = "center",
# fig.height = 3,
# Text size
size = "small"
)
if (knitr::is_html_output()) {
knitr::opts_chunk$set(dev = "png")
} else {
knitr::opts_chunk$set(dev = "pdf")
}
# Modify the size of the code chunks
# https://stackoverflow.com/questions/25646333/code-chunk-font-size-in-rmarkdown-with-knitr-and-latex
def.chunk.hook <- knitr::knit_hooks$get("chunk")
knitr::knit_hooks$set(chunk = function(x, options) {
x <- def.chunk.hook(x, options)
ifelse(options$size != "normalsize", paste0("\n \\", options$size, "\n\n", x, "\n\n \\normalsize"), x)
})
```
```{css echo=FALSE}
code {
font-family: Hack, monospace;
font-size: 85%;
padding: 0;
padding-top: 0.2em;
padding-bottom: 0.2em;
background-color: rgba(0,0,0,0.04);
border-radius: 3px;
}
code:before,
code:after {
letter-spacing: -0.2em;
content: "\00a0";
}
```
<!--- Better HTML output --->
```{css echo=FALSE}
pre {
font-family: Hack, monospace;
font-size: 75%;
margin-left: 15%;
#padding: 25%;
padding-top: 0.2em;
padding-bottom: 0.2em;
background-color: rgba(0,0,255,0.1);
#border-radius: 10px;
}
```
```{r preamble,echo=FALSE,message=FALSE}
### Preamble
# Usual libraries
library(tidyverse)
library(lubridate)
library(gridExtra)
# Evaluation metrics including RMSE
library(Metrics)
# Data partitioning, machine learning models, training and prediction
library(caret)
# Use ds_theme_set()
library(dslabs)
ds_theme_set()
# Make things pretty
library(kableExtra)
library(RColorBrewer)
library(corrplot)
```
```{r echo=FALSE,message=FALSE}
## Coding style
# - The code makes heavy uses of tidyverse functions even when there would be more concise
# ways to write it. As the expression goes _"Premature optimisation is the root of all evil."_
#
# - local({ ... }) is used when temporary variables are needed. Executing within a local
# scope avoids cluttering the environment with those variables.
```