Skip to content

Commit

Permalink
Edits to Chapter 1. Closes #1.
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasilge committed Jun 17, 2019
1 parent 1087c07 commit cfeff0b
Show file tree
Hide file tree
Showing 20 changed files with 829 additions and 776 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ yarn-error.log
.pnp.js
# Yarn Integrity file
.yarn-integrity
.Rproj.user
506 changes: 253 additions & 253 deletions chapters/chapter1.md

Large diffs are not rendered by default.

30 changes: 16 additions & 14 deletions exercises/exc_01_06.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
library(tidyverse)
cars_vars <- readRDS("/usr/local/share/datasets/c1_cars_vars_full.rds")

# Load caret
___

# Split the data into training and test sets
set.seed(1234)
in_train <- createDataPartition(cars_vars$___, p = ___, list = FALSE)
training <- cars_vars[___, ]
testing <- cars_vars[___, ]



library(tidyverse)
cars_vars <- readRDS("/usr/local/share/datasets/c1_cars_vars_full.rds")

# Load rsample
___

# Split the data into training and test sets
set.seed(1234)
in_train <- car_vars %>%
initial_split(prop = ___, strata = "___")

car_train <- training()
car_test <- testing()



34 changes: 18 additions & 16 deletions exercises/exc_01_07_1.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
library(caret)
library(tidyverse)

training <- readRDS("/usr/local/share/datasets/c1_training_full.rds")
testing <- readRDS("/usr/local/share/datasets/c1_testing_full.rds")

# Load caret
___

# Train a linear regression model
fit_lm <- train(log(MPG) ~ ., method = ___, data = ___,
trControl = trainControl(method = "none"))

# Print the model object
fit_lm

library(caret)
library(tidyverse)

car_train <- readRDS("/usr/local/share/datasets/c1_training_full.rds")
car_test <- readRDS("/usr/local/share/datasets/c1_testing_full.rds")

# Load caret
___

# Train a linear regression model
fit_lm <- train(log(MPG) ~ .,
method = ___,
data = ___,
trControl = trainControl(method = "none"))

# Print the model object
fit_lm

18 changes: 10 additions & 8 deletions exercises/exc_01_07_2.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Train a random forest model
fit_rf <- ___(log(MPG) ~ ., method = ___, data = ___,
trControl = trainControl(method = "none"))

# Print the model object
fit_rf


# Train a random forest model
fit_rf <- ___(log(MPG) ~ .,
method = ___,
data = ___,
trControl = trainControl(method = "none"))

# Print the model object
fit_rf


38 changes: 19 additions & 19 deletions exercises/exc_01_08.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
library(caret)
library(tidyverse)

training <- readRDS("/usr/local/share/datasets/c1_training_full.rds")
fit_lm <- readRDS("/usr/local/share/datasets/c1_fit_lm.rds")
fit_rf <- readRDS("/usr/local/share/datasets/c1_fit_rf.rds")

# Load yardstick
library(___)

# Create the new columns
results <- training %>%
mutate(`Linear regression` = predict(___, training),
`Random forest` = predict(___, training))

# Evaluate the performance
metrics(results, truth = ___, estimate = `Linear regression`)
metrics(results, truth = ___, estimate = `Random forest`)

library(caret)
library(tidyverse)

car_train <- readRDS("/usr/local/share/datasets/c1_training_full.rds")
fit_lm <- readRDS("/usr/local/share/datasets/c1_fit_lm.rds")
fit_rf <- readRDS("/usr/local/share/datasets/c1_fit_rf.rds")

# Load yardstick
library(___)

# Create the new columns
results <- car_train %>%
mutate(`Linear regression` = predict(___, training),
`Random forest` = predict(___, training))

# Evaluate the performance
metrics(results, truth = ___, estimate = `Linear regression`)
metrics(results, truth = ___, estimate = `Random forest`)

34 changes: 17 additions & 17 deletions exercises/exc_01_09.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
library(caret)
library(tidyverse)
library(yardstick)

testing <- readRDS("/usr/local/share/datasets/c1_testing_full.rds")
fit_lm <- readRDS("/usr/local/share/datasets/c1_fit_lm.rds")
fit_rf <- readRDS("/usr/local/share/datasets/c1_fit_rf.rds")

# Create the new columns
results <- ___ %>%
mutate(`Linear regression` = predict(fit_lm, ___),
`Random forest` = predict(fit_rf, ___))

# Evaluate the performance
metrics(results, truth = MPG, estimate = `Linear regression`)
metrics(results, truth = MPG, estimate = `Random forest`)

library(caret)
library(tidyverse)
library(yardstick)

car_test <- readRDS("/usr/local/share/datasets/c1_testing_full.rds")
fit_lm <- readRDS("/usr/local/share/datasets/c1_fit_lm.rds")
fit_rf <- readRDS("/usr/local/share/datasets/c1_fit_rf.rds")

# Create the new columns
results <- ___ %>%
mutate(`Linear regression` = predict(fit_lm, ___),
`Random forest` = predict(fit_rf, ___))

# Evaluate the performance
metrics(results, truth = MPG, estimate = `Linear regression`)
metrics(results, truth = MPG, estimate = `Random forest`)

33 changes: 19 additions & 14 deletions exercises/exc_01_11.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
library(caret)
library(tidyverse)

training <- readRDS("/usr/local/share/datasets/c1_training_one_percent.rds")

# Fit the models with bootstrap resampling
cars_lm_bt <- train(log(MPG) ~ ., method = "lm", data = ___,
trControl = trainControl(method = ___))
cars_rf_bt <- train(log(MPG) ~ ., method = "rf", data = ___,
trControl = ___(method = ___))

# Quick look at the models
cars_lm_bt
cars_rf_bt
library(caret)
library(tidyverse)

car_train <- readRDS("/usr/local/share/datasets/c1_training_one_percent.rds")

# Fit the models with bootstrap resampling
cars_lm_bt <- train(log(MPG) ~ .,
method = "lm",
data = ___,
trControl = trainControl(method = ___))

cars_rf_bt <- train(log(MPG) ~ .,
method = "rf",
data = ___,
trControl = ___(method = ___))

# Quick look at the models
cars_lm_bt
cars_rf_bt
28 changes: 14 additions & 14 deletions exercises/exc_01_12_1.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
library(caret)
library(tidyverse)
library(yardstick)

testing <- readRDS("/usr/local/share/datasets/c1_testing_full.rds")
cars_lm_bt <- readRDS("/usr/local/share/datasets/cars_lm_bt.rds")
cars_rf_bt <- readRDS("/usr/local/share/datasets/cars_rf_bt.rds")

results <- testing %>%
___(`Linear regression` = predict(cars_lm_bt, testing),
`Random forest` = predict(cars_rf_bt, testing))

metrics(results, ___ = MPG, ___ = `Linear regression`)
metrics(results, ___ = MPG, ___ = `Random forest`)
library(caret)
library(tidyverse)
library(yardstick)

car_test <- readRDS("/usr/local/share/datasets/c1_testing_full.rds")
cars_lm_bt <- readRDS("/usr/local/share/datasets/cars_lm_bt.rds")
cars_rf_bt <- readRDS("/usr/local/share/datasets/cars_rf_bt.rds")

results <- car_test %>%
___(`Linear regression` = predict(cars_lm_bt, testing),
`Random forest` = predict(cars_rf_bt, testing))

metrics(results, ___ = MPG, ___ = `Linear regression`)
metrics(results, ___ = MPG, ___ = `Random forest`)
21 changes: 11 additions & 10 deletions meta.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
{
"courseId": "course-starter-r",
"title": "My cool online course",
"slogan": "A free online course",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam tristique libero at est congue, sed vestibulum tortor laoreet. Aenean egestas massa non commodo consequat. Curabitur faucibus, sapien vitae euismod imperdiet, arcu erat semper urna, in accumsan sapien dui ac mi. Pellentesque felis lorem, semper nec velit nec, consectetur placerat enim.",
"bio": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam tristique libero at est congue, sed vestibulum tortor laoreet. Aenean egestas massa non commodo consequat. Curabitur faucibus, sapien vitae euismod imperdiet, arcu erat semper urna.",
"courseId": "supervised-ML-case-studies-course",
"title": "Supervised machine learning case studies in R!",
"slogan": "A free interactive course",
"description": "This is a free, open source course on supervised machine learning in R. In this course, you'll work through four case studies and practice skills from exploratory data analysis through model evaluation. <a href='https://ines.io/'>Ines Montani</a> designed the web framework that runs this course, and <a href='https://florencia.netlify.com/'>Florencia D'Andrea</a> helped build the site.</p><p>Contributions and comments on how to improve this course are welcome! Please <a href='https://github.com/juliasilge/supervised-ML-case-studies-course/issues'>file an issue</a> or submit a pull request if you find something that could be fixed or improved.</p>",
"bio": "Hello! My name is Julia Silge and I'm a data scientist at <a href='https://stackoverflow.com/'>Stack Overflow</a> where I use tidyverse tools and statistical analysis to understand developers and the software industry. I am both an international keynote speaker and a real-world practitioner focused on data analysis and machine learning practice. I love making beautiful charts and communicating about technical topics with diverse audiences. </p><p><a rel='license' href='http://creativecommons.org/licenses/by/4.0'><img alt='Creative Commons License' src='https://i.creativecommons.org/l/by/4.0/88x31.png'/></a></p>",
"siteUrl": "https://course-starter-r.netlify.com",
"twitter": "spacy_io",
"twitter": "juliasilge",
"fonts": "IBM+Plex+Mono:500|IBM+Plex+Sans:700|Lato:400,400i,700,700i",
"testTemplate": "success <- function(text) {\n cat(paste(\"\\033[32m\", text, \"\\033[0m\", sep = \"\"))\n}\n\n.solution <- \"${solutionEscaped}\"\n\n${solution}\n\n${test}\ntryCatch({\n test()\n}, error = function(e) {\n cat(paste(\"\\033[31m\", e[1], \"\\033[0m\", sep = \"\"))\n})",
"juniper": {
"repo": "ines/course-starter-r",
"repo": "juliasilge/supervised-ML-case-studies-course",
"branch": "binder",
"lang": "r",
"kernelType": "ir",
"debug": false
},
"showProfileImage": true,
"footerLinks": [
{ "text": "Website", "url": "https://spacy.io" },
{ "text": "Source", "url": "https://github.com/ines/course-starter-r" },
{ "text": "Built with ♥", "url": "https://github.com/ines/course-starter-r" }
{ "text": "Follow Me on Twitter", "url": "https://twitter.com/juliasilge" },
{ "text": "My Website", "url": "https://juliasilge.com/" },
{ "text": "Source Code on GitHub", "url": "https://github.com/juliasilge/supervised-ML-case-studies-course" },
{ "text": "Built with ♥ and Open Source", "url": "https://github.com/ines/course-starter-r" }
],
"theme": "#de7878"
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "course-starter-r",
"name": "supervised-ML-case-studies-course",
"private": true,
"description": "Starter package to build interactive R courses",
"description": "Supervised machine learning case studies in R! A free interactive course ",
"version": "0.0.1",
"author": "Ines Montani <[email protected]>",
"author": "Julia Silge <[email protected]>",
"dependencies": {
"@illinois/react-use-local-storage": "^1.1.0",
"@jupyterlab/outputarea": "^0.19.1",
Expand Down Expand Up @@ -52,6 +52,6 @@
},
"repository": {
"type": "git",
"url": "https://github.com/ines/course-starter-python"
"url": "https://github.com/juliasilge/supervised-ML-case-studies-course"
}
}
Loading

0 comments on commit cfeff0b

Please sign in to comment.