Description Usage Arguments Details Value Note References See Also Examples
Build, apply and visualize list-based rules directly using features and losses.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | build.rule(x, y,
maxlen = 10L, zeta = 0.1 * mean(y), eta = 0.05 * sum(y))
build.rule.cv(x, y,
kfolds = 5L, fold = NULL,
maxlen = 10L, zeta.choices = NULL, eta.choices = NULL,
cv.only = FALSE)
apply.rule(object, xnew, what = c("label", "index"))
show.rule(object, digits = 3L)
verbalize.rule(object, digits = 3L)
draw.rule(object, digits = 3L, filepath = NULL)
|
x |
A matrix of features. |
y |
A matrix of losses; |
maxlen |
A scalar for the maximum length of the list. |
zeta |
A scalar for tuning paramter zeta. Larger zeta tends to construct condition that covers more observations in each if-then clause. |
eta |
A scalar for tuning paramter eta. Larger eta tends to construct condition that uses less features in each if-then clause. |
kfolds |
A scalar for the number of folds for cross validation. |
fold |
An integer vector consisting of fold membership. |
zeta.choices |
A numeric vector for possible values of zeta in cross validation. |
eta.choices |
A numeric vector for possible values of eta in cross validation. |
cv.only |
A boolean scalar. If true, only cross validated losses are computed. Otherwise, the list built using the optimal zeta and eta is also computed. |
object |
Return value of |
xnew |
A matrix of features for prediction. |
what |
A scalar that determines the form in which the recommended treatment is represented. |
digits |
A scalar for the number of decimal digits to show. |
filepath |
A character scalar, if not null, that gives the location that the diagram will save to. |
See the reference if interested in the algorithm.
build.rule
returns a list.
build.rule.cv
returns a list as well as
cross validated losses.
apply.rule
returns a vector
of recommended actions.
show.rule
prints the rule in words
and returns it invisibly.
verbalize.rule
returns a data.frame
that contains conditions and actions separately
for each if-then clause.
draw.rule
returns a ggplot2 object
that contains the diagram.
Use these functions only when it is really necessary.
https://arxiv.org/abs/1606.01472
1 2 3 4 5 6 7 8 9 10 11 12 13 | x <- matrix(rnorm(200 * 10), 200, 10)
y <- cbind(
a1 = as.double(x[, 1] < 0) + rnorm(200, 0, 0.1),
a2 = as.double(x[, 2] > 0) + rnorm(200, 0, 0.1))
y[y < 0] <- 0
obj <- build.rule(x, y)
show.rule(obj)
draw.rule(obj)
xnew <- matrix(rnorm(1000 * 10), 1000, 10)
ynew <- apply.rule(obj, xnew)
table(factor(xnew[, 1] < 0) : factor(xnew[, 2] < 0), ynew)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.