Skip to content

Instantly share code, notes, and snippets.

@toyeiei

toyeiei/.R

Last active Nov 13, 2018
Embed
What would you like to do?
random forest in R
# 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
You can’t perform that action at this time.