n*********e 发帖数: 318 | 1 I am doing an R logistic regression exercise -
My question is - 是否要先从validation set 中删掉 dependent variable, 然后再 run
prediction?
谢谢。
--------------------
library(MASS)
attach(birthwt) #The famous 'low birth weight' data for logistic regression
index <- 1:dim(birthwt)[1]
test<- sample(index, trunc(length(index)/3))
train<-birthwt[-test,]
validation <- birthwt[test,]
logit.1<-glm(low~., data=train, family=binomial(link='logit'))
logit.1
#------------------------------
#这里是否要先从validation set 中删掉 dependent variable, 然后再 run
prediction???
#还是没有区别?
pred<-predict(logit.1, validation, type="response")
final<-data.frame(cbind(pred, validation[,1]))
names(final)<-c('pred','actual')
final[order(final$pred,decreasing=T),] | h***i 发帖数: 3844 | 2 你try一遍不就得了,这有啥好问的。
再 run
regression
【在 n*********e 的大作中提到】 : I am doing an R logistic regression exercise - : My question is - 是否要先从validation set 中删掉 dependent variable, 然后再 run : prediction? : 谢谢。 : -------------------- : library(MASS) : attach(birthwt) #The famous 'low birth weight' data for logistic regression : index <- 1:dim(birthwt)[1] : test<- sample(index, trunc(length(index)/3)) : train<-birthwt[-test,]
| n*********e 发帖数: 318 | 3 谢谢, try 了一遍, 结果一样。
> pred2<-predict(logit.1, validation[,-1], type='response')
> sum(pred-pred2)
[1] 0
----------------------------
直说已想问一下, 是因为之后还要照样做svn, neural net, tree, random forest
看过网上的 例子, 有的人从validation set 中删掉 dependent variable, 然后
再 run prediction; 有的人直接在完整的validation set 上 run prediction
想知道有没有 Good R Coding Practice? | a***d 发帖数: 336 | 4 I think if a package is well written, and you input the data as a data.frame
, there is no need to remove the dependent variable. The program will find
the corresponding independent variables by their names and do the prediction
.
【在 n*********e 的大作中提到】 : 谢谢, try 了一遍, 结果一样。 : > pred2<-predict(logit.1, validation[,-1], type='response') : > sum(pred-pred2) : [1] 0 : ---------------------------- : 直说已想问一下, 是因为之后还要照样做svn, neural net, tree, random forest : 看过网上的 例子, 有的人从validation set 中删掉 dependent variable, 然后 : 再 run prediction; 有的人直接在完整的validation set 上 run prediction : 想知道有没有 Good R Coding Practice?
| n*********e 发帖数: 318 | 5 谢谢 无可云证!
另外, 想多问一下, 大家用 R 平常是怎么 run 10-fold cross-validation 的呢? | f*******6 发帖数: 103 | 6 when I run the logistic regression, I didn't remove the dependent variable.
It seems correct
frame
prediction
【在 a***d 的大作中提到】 : I think if a package is well written, and you input the data as a data.frame : , there is no need to remove the dependent variable. The program will find : the corresponding independent variables by their names and do the prediction : .
|
|