Python
Materials for class on Monday, April 29, 2019
Contents
Tweet of the day
Just released Altair version 3.0! This is a huge update, with many new visualization features and bug-fixes thanks to the hard work of the ??? team.
— Jake VanderPlas (@jakevdp) April 26, 2019
Check it out: https://t.co/PCyrIOTcvv pic.twitter.com/0YT2ckQizl
Altair is based on Vega and Vega-Lite, another creation by Jeff Heer and his lab. You can try Vega and Vega-lite here! There is also a vegalite R package.
Lab: Python+R (reticulate) in a Docker Container
1. Run RStudio’s ML Docker Image in one of these ways:
Did you know, this docker image also includes Machine Learning packages (for CPU) like h2o, tensorflow, and keras! It can expand to GPU environments too!
Easiest option (free, no local install): play-with-docker
Will take time to install (free): local Docker
Will cost money: Digital Ocean Droplet
3. Open RStudio via port 8787
FYI: username: rstudio, pwd: whatever you chose
4. Importing python packages
# run in RStudio console/file
# fyi reticulate is prepackaged
library(reticulate)
os <- import("os")
os$listdir(".")
5. Installing python packages
- Run this in RStudio terminal:
Restart RStudio session (Session > Restart R)
Run this in RStudio console:
Altair via Jupyter Docker install (“no R”)
1. Altair Jupyter notebook installation
# see https://jupyter-docker-stacks.readthedocs.io/en/latest/
docker run -p 8888:8888 jupyter/minimal-notebook:17aba6048f44
2. Open the Jupyter notebook in port 8888
3. Open terminal via Jupyter and run:
conda install -c conda-forge altair vega_datasets notebook vega
git clone https://github.com/altair-viz/altair-tutorial.git
4. Navigate to the notebook “01-Cars-Demo.ipynb”
See the folder “/altair-tutorial/notebooks/”.