0

I am trying to apply Gradient Boosting to the MNIST dataset.

library(gbm)
boost_mnist<-gbm(Label~ .,data=mnist_train, distribution="bernoulli", n.trees=70, interaction.depth=4, shrinkage=0.3)

yhat_boost<-predict(boost_mnist, newdata=mnist_test, n.trees=70)
mean((yhat_boost-mnist_test)^2)

It gives the result:

"argument is not numeric or logical: returning NA[1] NA"

What is the problem here? Is it caused at the time of partition into train and test sets? If not, can anyone show the code to run the boosting?

N.B. I used the following code to do the partition:

set.seed(2)
mnist_num <- as.data.frame(lapply(mnist[1:10000,], as.numeric)) %>%mutate(id = row_number())
one = as.numeric(mnist_num$Label-1 == "1")
mnist_num$Label <- one
mnist_train <- sample_frac(mnist_num, .70)
mnist_test <- anti_join(mnist_num, mnist_train, by = 'id')
mnist_num$Label
UseR10085
  • 7,120
  • 3
  • 24
  • 54

0 Answers0