Course preparation for "A Statistical View of Deep Learning in Ecology" a short course at the virtual International Statistical Ecology Conference in June of 2020.

At a minimum, please read the "set up your workspace" section and install the caret package in R. If you have more time, please go through the this entire document. Warning: installation of some of these packages can take some time to complete.

This class has a wide range of students in terms of statistical knowledge, ecological knowledge, and even geography. This document reflects that. Wherever you are on the learning curve, I hope that you'll learn something new from this course. And, I hope that you, the students in the course, will work together to help one another learn more about machine learning and deep learning during and after the course.

Set up your workspace

R and RStudio

For the coding sections, we recommend that you set up your workspace for zoom/coding as explained at the bottom of Gordana Popovic's page on installing R studio.


R software for the shortcourse

R caret package: To install the caret package, you can use the menus in RStudio or run this command in the console. This package takes some time to install because it requires the installation of many other packages.

install.packages("caret")

R tidymodels package: This is a new package that might be even more powerful than caret and it fits within the tidyverse. There are currently more materials available about caret, but I predict that tidymodels will become eventually dominant. Note: the course instructors don't have a lot of expertise yet with the tidymodels package.

install.packages("tidymodels")

R keras package

I had planned to use the R keras package for this short course as I have taught classes using it previously. However, multiple people are having trouble getting the current version to work on their machine. Feel free to skip this section if you like.

Depending on your computer set-up installing the R keras package may be very challenging. The R keras package appears to be unstable as this problem comes and goes over time when R and the python packages are updated. I've included this information in the hope that some students will get it to work and/or you may use a later version of the package once the package again becomes stable.

  • The R package called keras is an R interface for the Python-based Keras library which runs on the TensorFlow platform. Yes, it is confusing to have keras (R) and Keras (Python)!

  • Rstudio's keras pages.
  • The Python-based Keras package is an API. An application programming interface (API) is a program which allows multiple software packages to interact. Keras is a neural network API that can run either TensorFlow or Theano. The Python-based Keras package webpage is useful for understanding details of the functions you'll be using.
  • The R package keras requires you to install both Keras and TensorFlow.
  • There are other R packages that you can use to access Keras. Read more here.

Installing the R keras package

Currently you can't get keras from CRAN. You can install the keras R package from GitHub as follows:

install.packages("devtools")
devtools::install_github("rstudio/keras")

Note: for some people the installation of devtools appears to stall, but it is probably just taking a lont time. Two options are to wait longer or restart Rstudio and rerun the above lines. The install_keras() line below may also take a very long time to finish.

The R package keras accesses the Python library called Keras. Keras runs on the TensorFlow platform. To install Keras and TensorFlow, use the following code.

library(keras)
install_keras()

Use this to check that your installation is working (from the Rstudio's keras page: https://keras.rstudio.com/)

library(keras)
mnist <- dataset_mnist()

For more sophisticated deep learning installations (such as using NVIDIA GPUs), see the documentation for install_keras().

Problems installing the keras package?

First, do you have the latest version of R and R Studio? I've had some students have to uninstall and reinstall R and RStudio to get things to work. Also, exiting R Studio and re-entering it can fix some problems.

One hint that may work: Install and load the "reticulate" package. Then from within RStudio, run the function reticulate::install_miniconda(). Then run install_keras().

More problems? You'll need to do some sleuthing to get things working. Examine any the error messages in R. Try Googling the error message or maybe try another R/keras interface like the kerasR package.

Still can't get keras to work from within R? For this shortcourse, you can try more modeling with the caret package. If you are new to neural networks, try nnet and mxnet from using the caret train function. There are some deep learning packages that you can access in caret like DeepBoost and deepnet. Finally, keras is R is still developing, so try back in a month or two.


Conclusion

Thanks for installing these packages before the course.

We will spend some time in the course applying machine learning and deep learning methods to data. I will provide additional code and tutorials during the course. If you have experience with some of these packages already, you may want to bring your own data to analyze during the course.

If you have any questions, please ask the course assistants during the shortcourse.