Skip to content

Instantly share code, notes, and snippets.

@mwacc
Created September 30, 2013 13:05
Show Gist options
  • Select an option

  • Save mwacc/6763528 to your computer and use it in GitHub Desktop.

Select an option

Save mwacc/6763528 to your computer and use it in GitHub Desktop.
Random forest on R example
#install.packages("randomForest")
library(randomForest)
train = read.csv(file="D:\\work\\R\\train.csv",head=TRUE,sep=",")
test = read.csv(file="D:\\work\\R\\test.csv",head=TRUE,sep=",")
rf = randomForest(ACTION ~ RESOURCE+MGR_ID+ROLE_DEPTNAME+ROLE_FAMILY_DESC+ROLE_ROLLUP_2+ROLE_ROLLUP_1+ROLE_TITLE+ROLE_CODE, data=train, importance=TRUE, ntree=250, mtry=3)
prediction = predict(rf, test)
write.csv(prediction, "D:\\work\\R\\out.csv", row.names=FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment