@shuvayan wrote:
Hello,
I have been trying to break the 96% accuracy barrier in the Digit Recognizer problem for a long time but nothing seemed to work until I finally laid my hands on the deep learning module in h2o library in R.It helped me break into the 97% accuracy slab.The code is very small and sweet(compared to the other things I had tried before).I am sharing it here on AV in case anyone wants to get a headstart.
library(h2o) localH2O = h2o.init(ip = "localhost", port = 54321, startH2O = TRUE,min_mem_size = "3g") ## Import MNIST CSV as H2O: mnistPath = '/home/shuvayan/Downloads/Kaggle/DGr/train.csv' mnist.hex = h2o.importFile(path = mnistPath, destination_frame = "mnist.hex") train <- as.data.frame(mnist.hex) train$label <- as.factor(train$label) train_h2o <- as.h2o(train) #Training a deep learning model:---------------------------------------------------------# model <- h2o.deeplearning(x = 2:785, y = 1, training_frame = train_h2o, activation = "RectifierWithDropout", input_dropout_ratio = 0.2, hidden_dropout_ratios = c(0.5,0.5), balance_classes = TRUE, hidden = c(800,800), epochs = 500) #Predict on test data: test_h2o <- h2o.importFile(path = '/home/shuvayan/Downloads/Kaggle/DGr/test.csv', destination_frame = "test_h2o") yhat <- h2o.predict(model, test_h2o) ImageId <- as.numeric(seq(1,28000)) names(ImageId)[1] <- "ImageId" predictions <- cbind(as.data.frame(ImageId),as.data.frame(yhat[,1])) names(predictions)[2] <- "Label" write.table(as.matrix(predictions), file="DNN_pred.csv", row.names=FALSE, sep=",")
Posts: 1
Participants: 1
