forked from lgreski/datasciencectacontent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pml article on installing RGtk2 toolkit on OSX
- Loading branch information
Showing
5 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}}$. |