-
-
Save toyeiei/ed7525fbaf9e88760387033d01f70971 to your computer and use it in GitHub Desktop.
random forest in R
This file contains 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
# install.packages("randomForest") | |
library(randomForest) | |
# build random forest model | |
set.seed(123) | |
rf_model <- randomForest(Class ~ ., data = train_df) | |
# print model | |
print(rf_model) | |
# predict test data and compute accuracy | |
p <- predict(rf_model, newdata = test_df) | |
table(test_df$Class, p) | |
# p | |
# benign malignant | |
# benign 127 4 | |
# malignant 1 73 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment