party: Interfaces for party package for data science pipelines.

Description Usage Arguments Details Value Author(s) Examples

Description

Interfaces to party functions that can be used in a pipeline implemented by magrittr.

Usage

1
2
3

Arguments

data

data frame, tibble, list, ...

...

Other arguments passed to the corresponding interfaced function.

Details

Interfaces call their corresponding interfaced function.

Value

Object returned by interfaced function.

Author(s)

Roberto Bertolusso

Examples

 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
## Not run: 
library(intubate)
library(magrittr)
library(party)

## ntbt_cforest: Random Forest

### honest (i.e., out-of-bag) cross-classification of
### true vs. predicted classes
data("mammoexp", package = "TH.data")
#table(mammoexp$ME, predict(cforest(ME ~ ., data = mammoexp, 
#                                   control = cforest_unbiased(ntree = 50)),
#                           OOB = TRUE))

## Original function to interface
set.seed(290875)
cforest(ME ~ ., data = mammoexp, control = cforest_unbiased(ntree = 50))

## The interface puts data as first parameter
set.seed(290875)
ntbt_cforest(mammoexp, ME ~ ., control = cforest_unbiased(ntree = 50))

## so it can be used easily in a pipeline.
set.seed(290875)
mammoexp %>%
  ntbt_cforest(ME ~ ., control = cforest_unbiased(ntree = 50))

## ntbt_ctree: Conditional Inference Trees
airq <- subset(airquality, !is.na(Ozone))

## Original function to interface
set.seed(290875)
ctree(Ozone ~ ., data = airq, controls = ctree_control(maxsurrogate = 3))

## The interface puts data as first parameter
set.seed(290875)
ntbt_ctree(airq, Ozone ~ ., controls = ctree_control(maxsurrogate = 3))

## so it can be used easily in a pipeline.
set.seed(290875)
airq %>%
  ntbt_ctree(Ozone ~ ., controls = ctree_control(maxsurrogate = 3))


## ntbt_mob: Model-based Recursive Partitioning
data("BostonHousing", package = "mlbench")
## and transform variables appropriately (for a linear regression)
BostonHousing$lstat <- log(BostonHousing$lstat)
BostonHousing$rm <- BostonHousing$rm^2
## as well as partitioning variables (for fluctuation testing)
BostonHousing$chas <- factor(BostonHousing$chas, levels = 0:1, 
                             labels = c("no", "yes"))
BostonHousing$rad <- factor(BostonHousing$rad, ordered = TRUE)

## Original function to interface
set.seed(290875)
mob(medv ~ lstat + rm | zn + indus + chas + nox + age + dis + rad + tax + crim + b + ptratio,
    control = mob_control(minsplit = 40), data = BostonHousing, 
    model = linearModel)

## The interface puts data as first parameter
set.seed(290875)
ntbt_mob(BostonHousing, 
         medv ~ lstat + rm | zn + indus + chas + nox + age + dis + rad + tax + crim + b + ptratio,
         control = mob_control(minsplit = 40), model = linearModel)

## so it can be used easily in a pipeline.
set.seed(290875)
BostonHousing %>%
  ntbt_mob(medv ~ lstat + rm | zn + indus + chas + nox + age + dis + rad + tax + crim + b + ptratio,
           control = mob_control(minsplit = 40), model = linearModel)

## End(Not run)

intubate documentation built on May 2, 2019, 2:46 p.m.