Use R randomForest package for Kaggle Digit Recognizer Challenge

Digit Recognizer

https://www.kaggle.com/c/digit-recognizer
Use R randomForest package for Digit Recognizer
The goal in this competition is to take an image of a handwritten single digit, and determine what that digit is. 
test <- read.csv("C:/Users/Liew Keong Han/Desktop/Machine Learning/test – Digit Recognizer.csv")
train <- read.csv("C:/Users/Liew Keong Han/Desktop/Machine Learning/train – Digit Recognizer.csv")
NumToTrain <- 42000
NumOfTrees <- 80
rows <- sample(1:nrow(train),NumToTrain)
labels <- as.factor(train[rows, 1])
train1 <- train[rows, -1]
rf <- randomForest(train1, labels, xtest = test , ntree=NumOfTrees)
predictions <- data.frame(ImageId =1:nrow(test), Label=levels(labels)[rf$test$predicted])
head(predictions)
tail(predictions)
str(predictions)
write_csv(predictions, “rf_42000_80-digit_recognizer.csv”)

Related Posts

One thought on “Use R randomForest package for Kaggle Digit Recognizer Challenge

Comments are closed.