Introduction to Machine Learning with the Tidyverse Workshop - rstudio::conf 2020

Introduction to Machine Learning with the Tidyverse Workshop

1/27/20—1/28/20
9:00 AM-5:00 PM
2 Day Workshop

Alison Hill
Data Scientist & Professional Educator
RStudio

Garrett Grolemund
Data Scientist and Master Instructor
RStudio


This workshop provides a gentle introduction to machine learning and to the tidyverse packages that do machine learning. You'll learn how to train and assess predictive models with several common machine learning algorithms, as well as how to do feature engineering to improve the predictive accuracy of your models. We will focus on learning the basic theory and best practices that support machine learning, and we will do it with a modern suite of R packages known as tidymodels. Tidymodels packages, like parsnip, recipes, and rsample provide a grammar for modeling and work seamlessly with R's tidyverse packages.

This workshop is appropriate for attendees who answer yes to the questions below:

  1. Can you use mutate and purrr to transform a data frame that contains list columns?
  2. Can you use the ggplot2 package to make a large variety of graphs?

If you answered no to either question, you can brush up on these topics by working through the online tutorials at https://rstudio.cloud/learn/primers.

If you already use machine learning methods like random forests, neural networks, cross-validation or feature engineering, this course is NOT for you; register for Max Kuhn's Applied Machine Learning Workshop instead.

1 Like

The prework for this workshop is now available here:

And here:

Please bring a laptop to class that has the following installed:

  • A recent version of R (>=3.6.0), which is available for free at
    cran.r-project.org

  • A recent version of RStudio Desktop (>=1.2.1500), available for
    free at www.rstudio.com/download (RStudio Desktop Open Source
    License)

  • The R packages we will use, which you can install by connecting to
    the internet, opening RStudio, and running at the command line:

    install.packages(c("tidyverse", "tidymodels", "remotes", 
                        "rpart.plot", "rattle", "vip", "AmesHousing", 
                        "kknn", "rpart", "ranger", "partykit"))
    
    # and
    
    remotes::install_github(c("tidymodels/workflows", "tidymodels/tune", "tidymodels/modeldata"))
    

And don’t forget your power cord!

On the day of the class, we’ll provide you with an RStudio Server Pro
login that contains all of the course materials. We will use the
software listed above only as an important backup should there be
problems with the classroom server connection.

2 Likes

Problem Completing Prework:

I was successful in installing the required packages. But, when running the remotes::install_github(... ) code, I then instructed "All" updates to be accomplished. This resulted in:

"There are binary versions available but the source versions are later
binary source needs_compilation
Binaries will be installed"

then....

Error: Failed to install 'workflows' from GitHub:
(converted from warning) cannot remove prior installation of package ‘Rcpp’

I'm not sure what to do now. Any guidance is appreciated. Thank you.

Try restarting R and run the remotes::install_github() section again.

If you use RStudio , use the menu item Session > Restart R or the associated keyboard shortcut Ctrl+Shift+F10 (Windows and Linux) or Command+Shift+F10 (Mac OS)

Hello,

When I ran remotes::install_github() , I selected '2: CRAN packages' only instead of '1: All'. Everything installed fine.

But after reading the previous posts, I'm wondering if I should go back and re-install remotes::install_github() and select '1: All'?

Thanks for your help.

1 Like

I'm having trouble with the prework. Please help. Error messages I'm seeing:

Installing package into ‘C:/Users/maymay/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)

  • installing source package 'workflows' ...
    ** using staged installation
    ** R
    ** data
    *** moving datasets to lazyload DB
    ** byte-compile and prepare package for lazy loading
    Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
    there is no package called 'zeallot'
    Calls: ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
    Execution halted
    ERROR: lazy loading failed for package 'workflows'
  • removing 'C:/Users/maymay/Documents/R/win-library/3.6/workflows'
    Error: Failed to install 'workflows' from GitHub:
    (converted from warning) installation of package ‘C:/Users/maymay/AppData/Local/Temp/RtmpQhIULd/file2c644cc92385/workflows_0.1.0.9000.tar.gz’ had non-zero exit status

It looks like you don't have zeallot installed.

Try running install.packages("zeallot") and try again

It worked. Thank you!

1 Like

Continuing the discussion from Introduction to Machine Learning with the Tidyverse Workshop - rstudio::conf 2020:

Hi,

When I am trying to install the R packages, I get the following error for rlang, tidyr, vctrs and stringi:

  • installing source package 'stringi' ... ** package 'stringi' successfully unpacked and MD5 sums checked ** using staged installation Warning in system("sh ./configure.win") : 'sh' not found ERROR: configuration failed for package 'stringi' * removing 'C:/Users/ruiza07/Documents/R/win-library/3.6/stringi' * restoring previous 'C:/Users/ruiza07/Documents/R/win-library/3.6/stringi' Warning in install.packages : installation of package ‘stringi’ had non-zero exit status * installing source package 'rlang' ... ** package 'rlang' successfully unpacked and MD5 sums checked ** using staged installation ** libs

*** arch - i386
C:/PROGRA~1/R/R-36~1.2/etc/i386/Makeconf:230: warning: overriding commands for target .m.o' C:/PROGRA~1/R/R-36~1.2/etc/i386/Makeconf:223: warning: ignoring old commands for target .m.o'
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -I./lib/ -O3 -Wall -std=gnu99 -mtune=generic -c capture.c -o capture.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -I./lib/ -O3 -Wall -std=gnu99 -mtune=generic -c export.c -o export.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -I./lib/ -O3 -Wall -std=gnu99 -mtune=generic -c internal.c -o internal.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -I./lib/ -O3 -Wall -std=gnu99 -mtune=generic -c lib.c -o lib.o
process_begin: CreateProcess(NULL, basename rlang.dll .dll, ...) failed.
process_begin: CreateProcess(NULL, basename rlang.dll .dll, ...) failed.
process_begin: CreateProcess(NULL, basename rlang.dll .dll, ...) failed.
"zcapture.o export.o internal.o lib.o" was unexpected at this time.
make: *** [rlang.dll] Error 255
ERROR: compilation failed for package 'rlang'

  • removing 'C:/Users/ruiza07/Documents/R/win-library/3.6/rlang'
  • restoring previous 'C:/Users/ruiza07/Documents/R/win-library/3.6/rlang'
    Warning in install.packages :
    installation of package ‘rlang’ had non-zero exit status
  • installing source package 'vctrs' ...
    ** package 'vctrs' successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs

*** arch - i386
C:/PROGRA~1/R/R-36~1.2/etc/i386/Makeconf:230: warning: overriding commands for target .m.o' C:/PROGRA~1/R/R-36~1.2/etc/i386/Makeconf:223: warning: ignoring old commands for target .m.o'
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c altrep-rle.c -o altrep-rle.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c arg-counter.c -o arg-counter.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c arg.c -o arg.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c bind.c -o bind.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c c.c -o c.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c cast.c -o cast.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c compare.c -o compare.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c conditions.c -o conditions.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c dictionary.c -o dictionary.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c equal.c -o equal.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c fields.c -o fields.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c group.c -o group.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c growable.c -o growable.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c hash.c -o hash.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c init.c -o init.o
In file included from init.c:6:0:
altrep-rle.h:23:25: warning: 'altrep_rle_class' defined but not used [-Wunused-variable]
static R_altrep_class_t altrep_rle_class;
^
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c names.c -o names.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c proxy-restore.c -o proxy-restore.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c proxy.c -o proxy.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c size-common.c -o size-common.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c size.c -o size.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c slice-array.c -o slice-array.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c slice-assign.c -o slice-assign.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c slice-chop.c -o slice-chop.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c slice.c -o slice.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c split.c -o split.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c subscript-loc.c -o subscript-loc.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c translate.c -o translate.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c type-data-frame.c -o type-data-frame.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c type-info.c -o type-info.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c type-list-of.c -o type-list-of.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c type.c -o type.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c type2-dispatch.c -o type2-dispatch.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c type2.c -o type2.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c unspecified.c -o unspecified.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c utils-dispatch.c -o utils-dispatch.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c utils.c -o utils.o
process_begin: CreateProcess(NULL, basename vctrs.dll .dll, ...) failed.
process_begin: CreateProcess(NULL, basename vctrs.dll .dll, ...) failed.
process_begin: CreateProcess(NULL, basename vctrs.dll .dll, ...) failed.
"zaltrep-rle.o arg-counter.o arg.o bind.o c.o cast.o compare.o conditions.o dictionary.o equal.o fields.o group.o growable.o hash.o init.o names.o proxy-restore.o proxy.o size-common.o size.o slice-array.o slice-assign.o slice-chop.o slice.o split.o subscript-loc.o translate.o type-data-frame.o type-info.o type-list-of.o type.o type2-dispatch.o type2.o unspecified.o utils-dispatch.o utils.o" was unexpected at this time.
make: *** [vctrs.dll] Error 255
ERROR: compilation failed for package 'vctrs'

  • removing 'C:/Users/ruiza07/Documents/R/win-library/3.6/vctrs'
  • restoring previous 'C:/Users/ruiza07/Documents/R/win-library/3.6/vctrs'
    Warning in install.packages :
    installation of package ‘vctrs’ had non-zero exit status
  • installing source package 'tidyr' ...
    ** package 'tidyr' successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs

*** arch - i386
C:/PROGRA~1/R/R-36~1.2/etc/i386/Makeconf:230: warning: overriding commands for target .m.o' C:/PROGRA~1/R/R-36~1.2/etc/i386/Makeconf:223: warning: ignoring old commands for target .m.o'
c:/Rtools/mingw_32/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -I"C:/Users/ruiza07/Documents/R/win-library/3.6/Rcpp/include" -O2 -Wall -mtune=generic -c RcppExports.cpp -o RcppExports.o
c:/Rtools/mingw_32/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -I"C:/Users/ruiza07/Documents/R/win-library/3.6/Rcpp/include" -O2 -Wall -mtune=generic -c fill.cpp -o fill.o
c:/Rtools/mingw_32/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -I"C:/Users/ruiza07/Documents/R/win-library/3.6/Rcpp/include" -O2 -Wall -mtune=generic -c melt.cpp -o melt.o
c:/Rtools/mingw_32/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -I"C:/Users/ruiza07/Documents/R/win-library/3.6/Rcpp/include" -O2 -Wall -mtune=generic -c simplifyPieces.cpp -o simplifyPieces.o
process_begin: CreateProcess(NULL, basename tidyr.dll .dll, ...) failed.
process_begin: CreateProcess(NULL, basename tidyr.dll .dll, ...) failed.
process_begin: CreateProcess(NULL, basename tidyr.dll .dll, ...) failed.
"zRcppExports.o fill.o melt.o simplifyPieces.o" was unexpected at this time.
make: *** [tidyr.dll] Error 255
ERROR: compilation failed for package 'tidyr'

  • removing 'C:/Users/ruiza07/Documents/R/win-library/3.6/tidyr'
  • restoring previous 'C:/Users/ruiza07/Documents/R/win-library/3.6/tidyr'
    Warning in install.packages :
    installation of package ‘tidyr’ had non-zero exit status

The downloaded source packages are in
‘C:\Users\ruiza07\AppData\Local\Temp\1\RtmpeSoTpM\downloaded_packages’

library(tidyverse)
Error: package or namespace load failed for ‘tidyverse’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
object 'vI' not found

Okay let us try to deal with this on in stages.

Try restarting R and then run `install.packages("rlang") and report back what you get.

If you use RStudio , use the menu item Session > Restart R or the associated keyboard shortcut Ctrl+Shift+F10 (Windows and Linux) or Command+Shift+F10 (Mac OS)

If that ones then try to install the other packages, else copy paste output back here for us :slight_smile:

Hi,

I installed one by one a dozen of packages until tidyverse library loaded correctly, then I proceeded with the rest of the packages. I noticed that parsnip, and 2 more packages were not installed and added as topics so I restarted R and installed them , then I proceeded with the github packages. No more errors, anyway to check that everything has been installed correctly and I am not missing any dependencies?

Thanks

Ana

If you can run the following code without errors you should be good!

library(tidyverse)
library(tidymodels)
library(remotes)
library(rpart.plot)
library(rattle)
library(vip)
library(AmesHousing)
library(kknn)
library(rpart)
library(ranger)
library(partykit)
library(workflows)
library(tune)
library(modeldata)
1 Like

Restart R did the trick. remotes::install_github() has now been successful. Many thanks! :slight_smile:

2 Likes

Hi @bec- if you were able to complete the installs successfully I would leave well enough alone :wink: You are all set!

Alison