由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - R classification tree model 请教
相关主题
在R中ifelse如何运用于variable recoding?categorical data analysis 一问
any regression model with high prediction accuracy?how to convert a categorical variable into a continuous variable
R 里 encoding 提问;包子答谢!一个最近才得到的一点经验
求教一个模型/预测问题问点统计问题(关于CFA和SEM的)
WHAT IS CART?刚结束的Capital One电面 写点儿面经给大家参考.
How to transform predictor variable?how to find cutoff points of a point scale 包子谢
a question on transformation做logistic regression,cases很少但是predictor很多
请问:Age 什么时候应该 ’分段', 什么时候不分呢?CONTINUOUS PREDICTOR AND BINARY OUTCOME
相关话题的讨论汇总
话题: factor话题: test话题: rpart话题: model
进入Statistics版参与讨论
1 (共1页)
n*****5
发帖数: 61
1
I used rpart. The dependent variable is categorical,and the predictors
includes both categorical and continuous variables.
Here is the model I used:
y<-factor(m$Y)
b<-factor(m$B)
test<-rpart(y~a+b+c,method="class", data=m)
But it always shows "Error in yval[, 1] : incorrect number of dimensions".
Any suggestion would be greatly appreciated!
f***a
发帖数: 329
2
If raw dataset is "m",
y <- factor(m$Y)
b <- factor(m$B)
dat <- data.frame(m[, !(names(dat) %in% c("B","Y"))],B=b,Y=y)
dat.rp <- rpart(Y~.,dat,method="class",cp=0.001)
This should work, at least for me.
Please check if you made mistake when transforming "m$Y" "m$B" into
factor. Factor is the most naughty data type in R.

dimensions".

【在 n*****5 的大作中提到】
: I used rpart. The dependent variable is categorical,and the predictors
: includes both categorical and continuous variables.
: Here is the model I used:
: y<-factor(m$Y)
: b<-factor(m$B)
: test<-rpart(y~a+b+c,method="class", data=m)
: But it always shows "Error in yval[, 1] : incorrect number of dimensions".
: Any suggestion would be greatly appreciated!

n*****5
发帖数: 61
3
I checked the factor variables, and didn't see anything wrong. Is it because
of the control parameters?
library(rpart)
test<-read.csv("H:\CBECS\r test\test.CSV",header=TRUE,sep=",")
names(test)
dim(test)
test$frame2<-factor(test$FRAME)
test$use<-factor(test$FRMACTVC)
names(test)
summary(test$frame2)
print(test$respond)
my.control<-c(minsplit=5,cp=0.001,maxcompete=1,maxsurrogate=1,
usesurrogate=2,surrogatestyle=1)
test.rp <- rpart(respond~ frame2+region+size_scf,data=test,
method="class",control=

【在 f***a 的大作中提到】
: If raw dataset is "m",
: y <- factor(m$Y)
: b <- factor(m$B)
: dat <- data.frame(m[, !(names(dat) %in% c("B","Y"))],B=b,Y=y)
: dat.rp <- rpart(Y~.,dat,method="class",cp=0.001)
: This should work, at least for me.
: Please check if you made mistake when transforming "m$Y" "m$B" into
: factor. Factor is the most naughty data type in R.
:
: dimensions".

f***a
发帖数: 329
4
I didn't see anything wrong except "test$use" wasn't used.
Do you have some sample data to share? So I can run and figure out where
is wrong.

because

【在 n*****5 的大作中提到】
: I checked the factor variables, and didn't see anything wrong. Is it because
: of the control parameters?
: library(rpart)
: test<-read.csv("H:\CBECS\r test\test.CSV",header=TRUE,sep=",")
: names(test)
: dim(test)
: test$frame2<-factor(test$FRAME)
: test$use<-factor(test$FRMACTVC)
: names(test)
: summary(test$frame2)

1 (共1页)
进入Statistics版参与讨论
相关主题
CONTINUOUS PREDICTOR AND BINARY OUTCOMEWHAT IS CART?
大家做过这个面试题吗?How to transform predictor variable?
攒人品,发Google Statistician/Data Scientist电面面经a question on transformation
加大伯克利分校著名科学家:大数据的“冬天”即将到来? (转载)请问:Age 什么时候应该 ’分段', 什么时候不分呢?
在R中ifelse如何运用于variable recoding?categorical data analysis 一问
any regression model with high prediction accuracy?how to convert a categorical variable into a continuous variable
R 里 encoding 提问;包子答谢!一个最近才得到的一点经验
求教一个模型/预测问题问点统计问题(关于CFA和SEM的)
相关话题的讨论汇总
话题: factor话题: test话题: rpart话题: model