wdsswadjsn
1, 问题开始/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
summary 函数 打印一个决策树节点, 为何variable importance 变量无法打印出来。
问题结束/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2,
代码开始/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
formula_Dece_Reg=本月超套标识~手机号码+地市+品牌+年龄+是否集团+性别+每月入网时长+是否高价值用户+欠费客户标识+总费用+月租费+通话费+流量
费+短信费+漫游通话次数+长途通话次数+点对点短信条数+其它短信条数+GPRS_CMNET次数+GPRS_CMWAP次数+主叫次数+节假日通话时长+当月通话对端号码
个数+是否智能手机+用户重点APP流量+用户本月TOP应用使用个数
#rp_Dece_Reg=rpart(formula_Dece_Reg,Train_Dece,method=json_data$json_data$table1[3])
rp_Dece_Reg=rpart(formula_Dece_Reg,Train_Dece,method="anova",cp=0.071)
#rp_Dece_Reg=rpart(formula_Dece_Reg,Train_Dece,cp=0.03)
print(rp_Dece_Reg)
printcp(rp_Dece_Reg)
summary(rp_Dece_Reg)
代码结束/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
代码输出开始/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
summary(rp_Dece_Reg)
Call:
rpart(formula = formula_Dece_Reg, data = Train_Dece, method = "anova",
cp = 0.071)
n= 32
CP nsplit rel error xerror xstd
1 0.1152074 0 1.0000000 1.068567 1.014850
2 0.0710000 1 0.8847926 1.306122 1.008967
Node number 1: 32 observations, complexity param=0.1152074
mean=0.96875, MSE=0.03027344
left son=2 (7 obs) right son=3 (25 obs)
Primary splits:
品牌 < 5 to the left, improve=0.11520740, (0 missing)
流量费 < 81.5 to the right, improve=0.11520740, (0 missing)
点对点短信条数 < 16 to the left, improve=0.11520740, (0 missing)
手机号码 < 15243290000 to the left, improve=0.09677419, (0 missing)
总费用 < 193.5 to the right, improve=0.08243728, (0 missing)
Surrogate splits:
点对点短信条数 < 7.5 to the left, agree=0.906, adj=0.571, (0 split)
地市 < 5.5 to the left, agree=0.875, adj=0.429, (0 split)
年龄 < 24.5 to the left, agree=0.875, adj=0.429, (0 split)
代码输出结束/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3,
个人想法和可能性:
1),是否决策树过度拟合就会导致节点的影响度为空?
如何判断是否过度拟合?
2),从 summary.rpart 函数内部的代码来看,这块加了一个非空判断:
if (!is.null(temp <- x$variable.importance)) {
temp <- round(100 * temp/sum(temp))
if (any(temp > 0)) {
cat("\nVariable importance\n")
print(temp[temp > 0])
}
}
但是此时决策树变量应该不为空。是否default调用了summary的其它版本?
如何指定调用某一类型的summary?
函数列表
> methods(summary)
[1] summary.aov summary.aovlist* summary.aspell*
[4] summary.connection summary.data.frame summary.Date
[7] summary.default summary.ecdf* summary.factor
[10] summary.glm summary.infl* summary.lm
[13] summary.loess* summary.manova summary.matrix
[16] summary.mlm* summary.nls* summary.packageStatus*
[19] summary.PDF_Dictionary* summary.PDF_Stream* summary.POSIXct
[22] summary.POSIXlt summary.ppr* summary.prcomp*
[25] summary.princomp* summary.proc_time summary.srcfile
[28] summary.srcref summary.stepfun summary.stl*
[31] summary.table summary.tukeysmooth*
感谢各位百忙之中抽空指教,谢谢。:)