rpart(rpart)
rpart()所属R语言包:rpart
Recursive Partitioning and Regression Trees
递归分割与回归树
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Fit a rpart model
适合一个rpart模型
用法----------Usage----------
rpart(formula, data, weights, subset, na.action = na.rpart, method,
model = FALSE, x = FALSE, y = TRUE, parms, control, cost, ...)
参数----------Arguments----------
参数:formula
a formula, with a response but no interaction terms.
公式的响应,但没有交互项。
参数:data
an optional data frame in which to interpret the variables named in the formula.
一个可选的数据框中解释公式中的变量。
参数:weights
optional case weights.
可选的情况下,权重。
参数:subset
optional expression saying that only a subset of the rows of the data should be used in the fit.
可选的表达式说只有一个子集的行的数据,应使用在拟合。
参数:na.action
the default action deletes all observations for which y is missing, but keeps those in which one or more predictors are missing.
的默认操作删除所有的观测y缺少,但仍保持在一个或多个预测丢失。
参数:method
one of "anova", "poisson", "class" or "exp". If method is missing then the routine tries to make an intelligent guess. If y is a survival object, then method="exp" is assumed, if y has 2 columns then method="poisson" is assumed, if y is a factor then method="class" is assumed, otherwise method="anova" is assumed. It is wisest to specify the method directly, especially as more criteria may added to the function in future. Alternatively, method can be a list of functions named init, split and eval. Examples are given in the file "tests/usersplits.R" in the sources.
"anova","poisson","class"或"exp"之一。 method如果缺少的日常试图做出明智的猜测。如果y是一种生存的对象,那么method="exp"假定,如果y有2列,那么method="poisson"假设,如果y是一个因素,那么method="class"假定,否则method="anova"假定。这是最明智的指定的方法,特别是作为直接更多的条件可能会添加到在将来的功能。另外,method是的列表命名init,split和eval的功能。例如在文件tests/usersplits.R来源。
参数:model
if logical: keep a copy of the model frame in the result? If the input value for model is a model frame (likely from an earlier call to the rpart function), then this frame is used rather than constructing new data.
如果逻辑的结果:保持复制的模型框架?如果输入的值model是一个模型框架(很可能是从以前调用rpart功能),然后使用这个框架,而不是兴建新的数据。
参数:x
keep a copy of the x matrix in the result.
x矩阵在结果中保留一份副本。
参数:y
keep a copy of the dependent variable in the result. If missing and model is supplied this defaults to FALSE.
保留一份副本中的因变量的结果。如果缺少和,model提供此默认为FALSE。
参数:parms
optional parameters for the splitting function.<br> Anova splitting has no parameters.<br> Poisson splitting has a single parameter, the coefficient of variation of the prior distribution on the rates. The default value is 1.<br> Exponential splitting has the same parameter as Poisson.<br> For classification splitting, the list can contain any of: the vector of prior probabilities (component prior), the loss matrix (component loss) or the splitting index (component split). The priors must be positive and sum to 1. The loss matrix must have zeros on the diagonal and positive off-diagonal elements. The splitting index can be gini or information. The default priors are proportional to the data counts, the losses default to 1, and the split defaults to gini.
可选参数的分裂功能。的参考方差分析分裂没有参数。参考泊松分裂有一个参数,系数的变化对利率的先验分布。默认值是1。<BR>指数的分裂具有相同的参数,如泊松。<br>对于分类分裂,列表可以包含任何向量的先验概率(元件prior),损失矩阵(组件loss)或分离度指数(组件split)。先验必须是积极的,总和为1。损耗矩阵必须具有上的对角线和积极的非对角(off-diagonal)的元素中的“0”。分离度指数可以gini或information。默认的先验是成比例的数据计数,默认为1的损失,和分割后的默认gini。
参数:control
a list of options that control details of the rpart algorithm. See rpart.control.
一个选项列表,控制rpart算法的细节。见rpart.control。
参数:cost
a vector of non-negative costs, one for each variable in the model. Defaults to one for all variables. These are scalings to be applied when considering splits, so the improvement on splitting on a variable is divided by its cost in deciding which split to choose.
非负的成本,一个用于在模型中的每个变量的矢量。默认为所有变量中的一个。这些都是结垢被应用时考虑的分裂,分裂一个变量除以它的成本在决定拆分选择的改善。
参数:...
arguments to rpart.control may also be specified in the call to rpart. They are checked against the list of valid arguments.
也可以指定在调用rpart.controlrpart的参数。它们是有效的参数列表中核对。
Details
详细信息----------Details----------
This differs from the tree function in S mainly in its handling of surrogate variables. In most details it follows Breiman et. al. quite closely. R package tree provides a re-implementation of tree.
这不同于tree主要表现在它的替代变量的处理功能在S。在最细节如下布雷曼博士等。人。有相当密切的。 R封装tree提供了一个重新执行tree。
值----------Value----------
An object of class rpart. See rpart.object.
对象的类rpart。见rpart.object。
参考文献----------References----------
Classification and Regression Trees. Wadsworth.
参见----------See Also----------
rpart.control, rpart.object, summary.rpart, print.rpart
rpart.control,rpart.object,summary.rpart,print.rpart
实例----------Examples----------
fit <- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)
fit2 <- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis,
parms=list(prior=c(.65,.35), split='information'))
fit3 <- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis,
control=rpart.control(cp=.05))
par(mfrow=c(1,2), xpd=NA) # otherwise on some devices the text is clipped[否则在某些设备上的文本被截断]
plot(fit)
text(fit, use.n=TRUE)
plot(fit2)
text(fit2, use.n=TRUE)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|