rpart.plot(rpart.plot)
rpart.plot()所属R语言包:rpart.plot
Plot an rpart model.
绘制的软件rpart的模型。
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Plot an rpart model. This function combines and extends plot.rpart and text.rpart in the rpart package. It automatically scales and adjusts the displayed tree for best fit.
画出一个rpart模型。此功能将扩展plot.rpart和text.rpartrpart包。自动缩放和调整,以获得最佳的显示树。
This is a front end to prp, with the most useful arguments of that function. See ../doc/prp.pdf for an overview.
这是一个前端prp,该函数的最有用的参数。查看/ DOC / prp.pdf的一个综述。
用法----------Usage----------
rpart.plot(x=stop("no 'x' arg"),
type=0, extra=0, under=FALSE, clip.right.labs=TRUE,
fallen.leaves=FALSE, branch=if(fallen.leaves) 1 else .2,
uniform=TRUE,
digits=2, varlen=-8, faclen=3,
cex=NULL, tweak=1,
compress=TRUE, ycompress=uniform,
snip=FALSE,
...)
参数----------Arguments----------
参数:x
An rpart object. The only required argument.
rpart对象。唯一需要的参数。
参数:type
Type of plot. Five possibilities: 0 The default. Draw a split label at each split and a node label at each leaf. 1 Label all nodes, not just leaves. Similar to text.rpart's all=TRUE. 2 Like 1 but draw the split labels below the node labels. Similar to the plots in the CART book. 3 Draw separate split labels for the left and right directions. 4 Like 3 but label all nodes, not just leaves. Similar to text.rpart's fancy=TRUE. See also clip.right.labs.<br>
图类型。五可能性:0默认值。绘制分割标签,在每个分割和每一片叶子节点标签。 1标签的所有节点,不只是离开了。类似“text.rpart的all=TRUE。 2像1“但画分割标签的节点下方的标签。类似的图在购物车中的书。 3绘制单独分割为左,右方向的标签。 4喜欢3“但标签的所有节点,不只是离开了。类似“text.rpart的fancy=TRUE。请参阅clip.right.labs。<BR>
参数:extra
Display extra information at the nodes. Possible values: 0 No extra information (the default). 1 Display the number of observations that fall in the node (per class for class objects; prefixed by the number of events for poisson and exp models). Similar to text.rpart's use.n=TRUE. 2 Class models: display the classification rate at the node, expressed as the number of correct classifications and the number of observations in the node.<br> Poisson and exp models: display the number of events. 3 Class models: misclassification rate at the node, expressed as the number of incorrect classifications and the number of observations in the node. 4 Class models: probability per class of observations in the node (conditioned on the node, sum across a node is 1). 5 Class models: like 4 but do not display the fitted class. 6 Class models: the probability of the second class only. Useful for binary responses. 7 Class models: like 6 but do not display the fitted class. 8 Class models: the probability of the fitted class. 9 Class models: the probabilities times the fraction of observations in the node (the probability relative to all observations, sum across all leaves is 1). +100 Add 100 to any of the above to also display the percentage of observations in the node. For example extra=101 displays the number and percentage of observations in the node. Actually, it's a weighted percentage using the weights passed to rpart.<br> Note: Unlike text.rpart, by default prp uses its own routine for generating node labels (not the function attached to the object). See node.fun.<br>
显示节点的额外信息。可能的值:0没有额外的信息(默认值)。 1显示数量的观察,在节点(每类class对象前缀poisson和exp模型)的事件数的。类似“text.rpart的use.n=TRUE。 2类模型:在节点中显示的分类率,表示正确的分类和若干意见的节点的数量。参考泊松和EXP模型的:显示事件的数量。 3类模型:在该节点上的误判率,表示为不正确的分类和观测值的数量在节点的数目。 4级车型:每类观测节点(节点上的空调,在一个节点的总和为1)的概率。 5级车型:,像4但不显示安装类。 6级车型:第二类的概率。有用的二进制反应。 7级车型:,像6但不显示安装类。 8级车型的拟合类的概率。 9级车型:的概率倍的部分观测节点(相对于所有观测值的概率,在所有叶子的总和为1)。 +100添加100任何上述也显示节点中的观测值的百分比。例如extra=101显示观测节点的数量和比例。其实,这是一个加权百分比weights传递给rpart。<br>注意:不同text.rpart,默认情况下,prp生成节点标签(而不是使用它自己的日常附加到该对象的功能)。见node.fun。<BR>
参数:under
Applies only if extra > 0. Default FALSE, meaning put the extra text in the box. Use TRUE to put the text under the box.
适用只有extra > 0。默认FALSE,意思是把多余的文本框中输入。使用TRUE把下面的文本框。
参数:clip.right.labs
Default is TRUE meaning “clip” the right-hand split labels, i.e. do not print variable=. Applies only if type=3 or 4.
默认是TRUE,意思是“夹”右侧的分割标签,即不打印variable=。适用于只有type=3或4。
参数:fallen.leaves
Default FALSE. If TRUE, display the leaves at the bottom of the graph.
默认FALSE。如果TRUE,显示在图形底部的叶子。
参数:branch
Controls the shape of the branch lines. Specify a value between 0 (V shaped branches) and 1 (square shouldered branches). Default is if(fallen.leaves) 1 else .2.
控制的分支线的形状。 0(V形分支之间指定一个值)和1(方肩分行)。默认是if(fallen.leaves) 1 else .2。
参数:uniform
If TRUE (the default), the vertical spacing of the nodes is uniform. If FALSE, the nodes are spaced proportionally to the fit (more precisely, to the difference between a node's deviance and the sum of its two children's deviances). Small vertical spaces are automatically artificially expanded to make room for the labels. Note: uniform=FALSE with cex=NULL (the default) can sometimes cause very small text.
如果TRUE(默认值),节点的垂直间距是一致的。如果FALSE,节点隔开比例的拟合(更精确地,节点的偏差和之间的差的总和,它的两个孩子的deviances)。小垂直空格将自动被人为地扩大的标签,以腾出空间。注:uniform=FALSE与cex=NULL(默认值),有时会导致非常小的文本。
参数:digits
The number of significant digits in displayed numbers. Default 2. If 0, use getOption("digits"). Details: Numbers from 0.001 to 9999 are printed without an exponent (and the number of digits is actually only a suggestion, see format for details). Otherwise an “engineering” exponent is used (a multiple of 3).
显着的数字显示的数字。默认2。如果0,在使用getOption("digits")。详细信息:数字0.0019999打印不带指数(数的数字其实只是一个建议,请参阅format)。否则,“工程”指数(3的倍数)。
参数:varlen
Length of variable names in text at the splits (and, for class responses, the class in the node label). Default -8, meaning truncate to eight characters. Possible values:<br> =0 use full names.<br> >0 call abbreviate with the given varlen.<br> <0 truncate variable names to the shortest length where they are still unique, but never truncate to shorter than abs(varlen).
文本的分裂(对于类的反应,节点标签中的类)的变量名的长度。默认-8,这意味着截断为八个字符。可能的值:参考= 0使用的全名。参考> 0调用abbreviate给定的varlen。<0截断变量名以最短的长度,他们仍然唯一的,但从来没有截断较短的比abs(varlen)。
参数:faclen
Length of factor level names in splits. Default 3, meaning abbreviate to three characters. Possible values are as varlen above, except that 1 is treated specially, meaning represent the factor levels with alphabetic characters (a for the first level, b for the second, etc.).
分裂因子的级别名称的长度。默认3,意为abbreviate三个大字。可能的值是varlen以上,除了1经过特殊处理,这意味着代表因子水平与字母字符(a的第一级,b第二,等等)。
参数:cex
Default NULL, meaning calculate the text size automatically.
默认NULL,自动计算文字大小。
参数:tweak
Adjust the (possibly automatically calculated) cex. Default 1, meaning no adjustment. Use say tweak=1.2 to make the text 20% larger. Note that font sizes are discrete, so the cex you ask for may not be the cex you get. And a small tweak may not actually change the type size or change it more than you want.
调整(可能自动计算)cex的。默认1,这意味着没有调整。用说tweak=1.2使文本20%以上。需要注意的是字体的大小是不连续的,所以cex你要求未必是cex你的。一个小的调整可能不会真正改变类型的大小或比你更想改变它。
参数:compress
If TRUE (the default), make more space by shifting nodes horizontally where space is available. This often allows larger text. (This is the same as plot.rpart's argument of the same name, except that here the default is TRUE.)
如果TRUE(默认值),使更多的空间,通过移动节点的水平位置的可用空间。这往往使较大的文本。 (这是plot.rpart的参数相同的名称一样,只是,这里的默认值是TRUE)。
参数:ycompress
If TRUE (the default unless uniform=FALSE), make more space by shifting labels vertically where space is available. Actually, this only kicks in if the initial automatically calculated cex is less than 0.7. Use ycompress=FALSE if you feel the resulting display is too messy. In the current implementation, the shifting algorithm works a little better (allowing larger text) with type=1, 2, or 3.
如果TRUE(默认情况下,除非uniform=FALSE),垂直移位标签的可用空间,腾出更多的空间。其实,这只是踢中如果初始自动计算cex小于0.7。使用ycompress=FALSE,“如果你觉得显示的结果是太乱了。在当前的实现,移算法的工作好一点type=1,2或3(允许较大的文本)。
参数:snip
Default FALSE. Set TRUE to interactively trim the tree with the mouse. See ../doc/prp.pdf (or just try it).
默认FALSE。设置TRUE以交互方式修剪的树,用鼠标。请参阅.. / DOC / prp.pdf的(或只是尝试一下)。
参数:...
Extra arguments passed to prp and the plotting routines. Any of prp's arguments can be used.
额外的参数传递给prp和绘图程序。任何prps参数都可以使用。
值----------Value----------
The returned value is identical to that of prp.
返回的值是相同的prp。
(作者)----------Author(s)----------
Stephen Milborrow, borrowing heavily from the <code><a href="../../rpart/html/rpart.html">rpart</a></code>
package by Terry M. Therneau and Beth Atkinson,
and the R port of that package by Brian Ripley.
参见----------See Also----------
../doc/prp.pdf<br> prp<br> plot.rpart<br> text.rpart<br> rpart
是。/ DOC / prp.pdf的<BR>prp参考plot.rpart参考text.rpart参考rpart
实例----------Examples----------
data(ptitanic)
tree <- rpart(survived ~ ., data=ptitanic, cp=.02)
# cp=.02 because want small tree for demo[CP = 0.02,因为要小的树演示]
old.par <- par(mfrow=c(2,2))
# put 4 figures on one page[在一个页面上放4个数字]
rpart.plot(tree, main="default rpart.plot\n(type = 0, extra = 0)")
prp(tree, main="type = 4, extra = 6", type=4, extra=6, faclen=0)
# faclen=0 to print full factor names[faclen = 0打印全因子名称]
rpart.plot(tree, main="extra = 106, under = TRUE", extra=106, under=TRUE, faclen=0)
# the old way for comparison[旧的方式进行比较]
plot(tree, uniform=TRUE, compress=TRUE, branch=.2)
text(tree, use.n=TRUE, cex=.6, xpd=NA) # cex is a guess, depends on your window size[CEX是一个猜测,取决于你的窗口大小]
title("rpart.plot for comparison", cex=.6)
par(old.par)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|