Skip to content

Instantly share code, notes, and snippets.

@tylerknutson
Last active September 2, 2016 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylerknutson/974793975ca85b822ffc275e2d48cb15 to your computer and use it in GitHub Desktop.
Save tylerknutson/974793975ca85b822ffc275e2d48cb15 to your computer and use it in GitHub Desktop.
rfGrid = expand.grid(mtry = c(2,16,30))
m_rf = train(x=train_repNA, y=labels, method="rf", weights=weight, verbose=TRUE,
trControl=ctrl, metric="AMS")
m_rf$finalModel
rfTestPred = predict(m_rf, newdata=test_repNA, type="prob")
predicted = rep("b",550000)
predicted[rfTestPred[,2]>=threshold] = "s"
weightRank = rank(rfTestPred[,2], ties.method= "random")
submission = data.frame(EventId = testId, RankOrder = weightRank, Class =
predicted)
write.csv(submission, "rf_submission.csv", row.names=FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment