Skip to content

Instantly share code, notes, and snippets.

@tengpeng
Created February 6, 2016 01:32
Show Gist options
  • Save tengpeng/4cbea30b332a455e4e49 to your computer and use it in GitHub Desktop.
Save tengpeng/4cbea30b332a455e4e49 to your computer and use it in GitHub Desktop.
binary classification xgboost r
library(xgboost)
X = as.matrix(train[,-58])
y = train[,58]
numberOfClasses <- max(y) + 1
bst <- xgboost(data = X, label = y, max.depth = 2, eta = 1, nthread = 2, nround = 200, objective = "binary:logistic", verbose = 1)
pred = predict(bst, data.matrix(test[,-58]))
pred = as.numeric(pred > 0.5)
mean(as.numeric(pred > 0.5) != test$spam)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment