Problem while creating a csv file in R for Kaggle

r
kaggle

#1

Hello,

I seem to have a weird problem. To submit a csv file in The bike sharing demand Kaggle competititon, I am using rpart() and ctree() algorithms to make my model. I used this code->

fit <- rpart(registered ~ season+temp +humidity +holiday+workingday+weather+atemp +day+ hour + day_part+ day_type + windspeed, data=train)
pred1=predict(fit,test)
test$registered=pred1
fit <- rpart(casual ~ season+temp +humidity +holiday+workingday+m+weather+atemp +day+ hour + day_part+ day_type + windspeed, data=train)
pred2=predict(fit,test)
test$casual=pred2
test$count=test$registered+test$casual
s<-data.frame(datetime=test$datetime,count=test$count)
write.csv(s,file=“thirteen.csv”,row.names=FALSE)

and then using ctree()->

fit <- ctree(registered ~ season+temp +humidity +holiday+workingday+weather+atemp +day+ hour + day_part+ day_type + windspeed, data=train)
pred1=predict(fit,test)
test$registered=pred1
fit <- ctree(casual ~ season+temp +humidity +holiday+workingday+m+weather+atemp +day+ hour + day_part+ day_type + windspeed, data=train)
pred2=predict(fit,test)
test$casual=pred2
test$count=test$registered+test$casual
s<-data.frame(datetime=test$datetime,count=test$count)
write.csv(s,file=“thirteen.csv”,row.names=FALSE)

I only changed the rpart to ctree in the code. The problem is that in my submission file I am getting the second column heading as ‘count’ when using rpart and ‘registered’ when using ctree which is creating problems in submission. Even when I manually try to change the column name from registered to count and then save the file, Kaggle is not accepting it. Why is this happening? What to do? Is this a problem with my PC or RStudio?


#2

try and look it up at the Kaggle forum.


#3

you can also supply a vector of column names using names=c(“col1”,“col2”,…) to change the column names