Skip to content

Commit

Permalink
Add pml article on installing RGtk2 toolkit on OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
lgreski committed Aug 13, 2017
1 parent 3291884 commit 24cbe2c
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions markdown/pml-installingRattleOnMacOSX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## Installing Rattle on Macbook OSX

The `rattle` package is referenced during the *Practical Machine Learning* course in the Johns Hopkins Data Science Specialization as a mechanism to print nice looking tree diagrams from the model output generated by the `rpart` package. Unfortunately, the package has a dependency on the `gtk2` library that is not present by default on Mac OSX.

Therefore, students using OSX frequently post questions about how to install the components necessary to use the Rattle `fancyRpartPlot()` function.

After a fair amount of effort I was able to install rattle on Mac OS X Sierra.

The install requires the gtk toolkit, and on Mac one must do the following, per a solution on [stackoverflow.com](https://stackoverflow.com/questions/15868860/r-3-0-and-gtk-rgtk2-error).

1. [Install macports](https://www.macports.org/install.php) — tool for installing mac packages <br><br>
2. run SUDO to install gtk2 on mac<br> `sudo port install gtk2 ## (X11 -- not aqua)`<br><br>
3. export new path <br>`export PATH=/opt/local/bin:/opt/local/sbin:$PATH`<br><br>
4. From RStudio, install rgtk2 with<br> `install.packages(“RGtk2”)` including compile<br><br>

The most complete set of instructions is located at [Sebastian Kopf's Gist page](https://gist.github.com/sebkopf/9405675) and verified by my own install on June 17, 2017. Once installed, loading the rattle library will generate the following output in the R console.

<img src="./images/pml-installingRattleOnMacOSX01.png">

In order to use `fancyRpartPlot()`, students will also need to install the `rpart.plot` package.

install.packages("rpart.plot")

## Example: Fancy Rpart Plot of Iris Data

Here we've replicated the code needed to generate a fancy tree diagram with `caret` and `rattle` that is discussed in the *Practical Machine Learning* lecture on *Predicting with Trees*.

library(caret)
library(rattle)
inTrain <- createDataPartition(y = iris$Species,
p = 0.7,
list = FALSE)
training <- iris[inTrain,]
testing <- iris[-inTrain,]
modFit <- train(Species ~ .,method = "rpart",data = training)
fancyRpartPlot(modFit$finalModel)

<img src="./images/pml-installingRattleOnMacOSX02.png">
Binary file added resources/2010LSIexcerpt.pdf
Binary file not shown.
18 changes: 18 additions & 0 deletions statinf-integralCalculations.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: "statinf-integralCalculations"
author: "Len Greski"
date: "8/5/2017"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Fixed Integral of a Point

$\int_{a}^{a} f(x) dx = 0$

## Standard Deviation from Census Table Data

$s = \frac{x_{5 ptile}-\bar{x}}{Z_{5 ptile}}$.

0 comments on commit 24cbe2c

Please sign in to comment.