-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
74 lines (53 loc) · 1.84 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# broomstick
<!-- badges: start -->
[![R build status](https://github.com/njtierney/broomstick/workflows/R-CMD-check/badge.svg)](https://github.com/njtierney/broomstick/actions)
[![Codecov test coverage](https://codecov.io/gh/njtierney/broomstick/branch/master/graph/badge.svg)](https://codecov.io/gh/njtierney/broomstick?branch=master)
[![R-CMD-check](https://github.com/njtierney/broomstick/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/njtierney/broomstick/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
Convert decision tree objects into tidy data frames with `broomstick`.
The goal of broomstick is to extend the [`broom`](https://github.com/tidyverse/broom) package to work with decision trees. It is currently borrowing heavily from the prototype package [`treezy`](https://github.com/njtierney/treezy).
## Installation
You can install broomstick from github with:
```{r gh-installation, eval = FALSE}
# install.packages("remotes")
remotes::install_github("njtierney/broomstick")
```
## Examples
## rpart
```{r example-rpart}
library(rpart)
library(broomstick)
fit_rpart <- rpart(Kyphosis ~ Age + Number + Start,
data = kyphosis)
tidy(fit_rpart)
augment(fit_rpart)
```
## gbm (Boosted Regression Tree)
```{r example-gbm}
library(gbm)
library(MASS)
fit_gbm <- gbm(calories ~., data = UScereal)
tidy(fit_gbm)
```
## random forest
```{r example-rf}
library(randomForest)
ozone_rf <- randomForest(Ozone ~ .,
data = airquality,
importance = TRUE,
na.action = na.omit)
tidy(ozone_rf)
glance(ozone_rf)
augment(ozone_rf)
```