-
-
Save tengpeng/4cbea30b332a455e4e49 to your computer and use it in GitHub Desktop.
binary classification xgboost r
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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