RWeka: Interfaces for RWeka package for data science pipelines.

Description Usage Arguments Details Value Author(s) Examples

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

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
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
## Not run: 
library(intubate)
library(magrittr)
library(RWeka)

## R/Weka Attribute Evaluators
## Original function to interface
GainRatioAttributeEval(Species ~ . , data = iris)
InfoGainAttributeEval(Species ~ . , data = iris)

## The interface puts data as first parameter
ntbt_GainRatioAttributeEval(iris, Species ~ .)
ntbt_InfoGainAttributeEval(iris, Species ~ .)

## so it can be used easily in a pipeline.
iris %>%
  ntbt_GainRatioAttributeEval(Species ~ .)
iris %>%
  ntbt_InfoGainAttributeEval(Species ~ .)

## R/Weka Classifier Functions
data(infert)
infert$STATUS <- factor(infert$case, labels = c("control", "case"))

## Original function to interface
LinearRegression(weight ~ feed, data = chickwts)
Logistic(STATUS ~ spontaneous + induced, data = infert)
SMO(Species ~ ., data = iris, control = Weka_control(K = list("RBFKernel", G = 2)))

## The interface puts data as first parameter
ntbt_LinearRegression(chickwts, weight ~ feed)
ntbt_Logistic(infert, STATUS ~ spontaneous + induced)
ntbt_SMO(iris, Species ~ ., control = Weka_control(K = list("RBFKernel", G = 2)))

## so it can be used easily in a pipeline.
chickwts %>%
  ntbt_LinearRegression(weight ~ feed)
infert %>%
  ntbt_Logistic(STATUS ~ spontaneous + induced)
iris %>%
  ntbt_SMO(Species ~ ., control = Weka_control(K = list("RBFKernel", G = 2)))

## R/Weka Lazy Learners
## No examples provided. LBR seems to need 'lazyBayesianRules'
## and I am too lazy myself to install it
ntbt_IBk(chickwts, weight ~ feed)   ## Example may not make sense


## R/Weka Meta Learners
## MultiBoostAB needs Weka package 'multiBoostAB'
## CostSensitiveClassifier throws an error

## Original function to interface
AdaBoostM1(Species ~ ., data = iris, control = Weka_control(W = "DecisionStump"))
Bagging(Species ~ ., data = iris, control = Weka_control())
LogitBoost(Species ~ ., data = iris, control = Weka_control())
Stacking(Species ~ ., data = iris, control = Weka_control())

## The interface puts data as first parameter
ntbt_AdaBoostM1(iris, Species ~ ., control = Weka_control(W = "DecisionStump"))
ntbt_Bagging(iris, Species ~ ., control = Weka_control())
ntbt_LogitBoost(iris, Species ~ ., control = Weka_control())
ntbt_Stacking(iris, Species ~ ., control = Weka_control())

## so it can be used easily in a pipeline.
iris %>%
  ntbt_AdaBoostM1(Species ~ ., control = Weka_control(W = "DecisionStump"))
iris %>%
  ntbt_Bagging(Species ~ ., control = Weka_control())
iris %>%
  ntbt_LogitBoost(Species ~ ., control = Weka_control())
iris %>%
  ntbt_Stacking(Species ~ ., control = Weka_control())

## R/Weka Rule Learners
## Original function to interface
JRip(Species ~ ., data = iris)
M5Rules(mpg ~ ., data = mtcars)
OneR(Species ~ ., data = iris)
PART(Species ~ ., data = iris)

## The interface puts data as first parameter
ntbt_JRip(iris, Species ~ .)
ntbt_M5Rules(mtcars, mpg ~ .)
ntbt_OneR(iris, Species ~ .)
ntbt_PART(iris, Species ~ .)

## so it can be used easily in a pipeline.
iris %>%
  ntbt_JRip(Species ~ .)
mtcars %>%
  ntbt_M5Rules(mpg ~ .)
iris %>%
  ntbt_OneR(Species ~ .)
iris %>%
  ntbt_PART(Species ~ .)

## R/Weka Classifier Trees
DF3 <- read.arff(system.file("arff", "cpu.arff", package = "RWeka"))
DF4 <- read.arff(system.file("arff", "weather.arff", package = "RWeka"))

## Original function to interface
DecisionStump(play ~ ., data = DF4)
J48(Species ~ ., data = iris)
LMT(play ~ ., data = DF4)
M5P(class ~ ., data = DF3)

## The interface puts data as first parameter
ntbt_DecisionStump(DF4, play ~ .)
ntbt_J48(iris, Species ~ .)
ntbt_LMT(DF4, play ~ .)
ntbt_M5P(DF3, class ~ .)

## so it can be used easily in a pipeline.
DF4 %>%
  ntbt_DecisionStump(play ~ .)
iris %>%
  ntbt_J48(Species ~ .)
DF4 %>%
  ntbt_LMT(play ~ .)
DF3 %>%
  ntbt_M5P(class ~ .)

## R/Weka Filters
w <- read.arff(system.file("arff","weather.arff", package = "RWeka"))

## Original function to interface
Discretize(play ~., data = w)
Normalize(~., data = w)

## The interface puts data as first parameter
ntbt_Discretize(w, play ~.)
ntbt_Normalize(w, ~.)

## so it can be used easily in a pipeline.
w %>%
  ntbt_Discretize(play ~.)
w %>%
  ntbt_Normalize(~.)

## End(Not run)

rbertolusso/intubate documentation built on May 27, 2019, 3 a.m.