Conversion to formula in R: Predict Y (factor variable) with X (data frame) -
i working on classification problem training info have info frame x
, factor variable y
, , predict variable y
x
.
the function cforest
party bundle has next interface
cforest(formula, info = list(), ...)
where:
formula: symbolic description of model fit. note symbols ':' , '-' not work , tree create utilize of variables listed on rhs of 'formula'.
data: info frame containing variables in model.
however, when try:
# build random set of training vectors x x <- data.frame(replicate(5, rnorm(2000))) # build y x y <- runif(1)*x[,1]*x[,2]^2+runif(1)*x[,3]/x[,4] cforest(y, info = x, ...)
i error:
.. 10: parseformula(formula, info = data) ... 5: cforest(y, info = x, ...) @ ..
from traceback looks not using interface cforest
correctly. have read r formulas (?formula
, this tutorial, helpful), , understand concept abstractly, don't know how convert prediction problem (which write y ~ x
) formula syntax.
how can convert phone call cforest
using formula?
the reply utilize next syntax:
cf.model = cforest(y ~ ., data=x, ...)
which says "use variables in dataframe x
when trying predict y
"
r
No comments:
Post a Comment