0

I have been stuck on this for some time, and am in need of some help. I am new to R and have never done Ridge Regression using GLMNET. I am trying to learn ML via the MNIST-fashion dataset (https://www.kaggle.com/zalando-research/fashionmnist). The streamline the training (to make sure it works before I attempt to train on the full dataset, I take a stratified random sample (which produces a training dataset of 60 - 6 observations per label):

MNIST.sample.train = sample.split(MNIST.train$label, SplitRatio=0.001)
sample.train = MNIST.train[MNIST.sample.train,]

Next, I attempt to run ridge regression, using alpha=1...

x=model.matrix(label ~ . ,data=sample.train)
y=sample.train$label
rr.m <- glmnet(x,y,alpha=1, family="multinomial")

This seems to work. However, when I attempt to run the prediction, I get an error:

Error in cbind2(1, newx) %% (nbeta[[i]]) : not-yet-implemented method for %% :

predict.rr.m <- predict(rr.m, MNIST.test, type = "class")

Ultimately, I am looking to obtain a single measure of the accuracy of the ridge regression. I believe that to do so, I must first obtain a prediction.

Any thoughts on how to fix my code would be greatly appreciated.

Kevin

Saurabh Chauhan
  • 3,161
  • 2
  • 19
  • 46
  • `label` is conceptually a factor variable. Ridge regression is the wrong approach for such data since it is for a continuous dependent variable. – Roland Aug 03 '18 at 05:52
  • Roland, that would explain it...I guess I should have looked into this before attempting RR using GLMNET. Does the same hold for LASSO Regression using GLMNET (glmnet with alpha=0)? – Kevin E Dow Aug 03 '18 at 06:08
  • I'm not an expert for this, but I believe you can use Ridge or LASSO regression only for continuous or ordinal dependent variables. A quick check with google indicates that `label` encodes fashion labels which appear to be neither. – Roland Aug 03 '18 at 06:18
  • @Roland This is not the case; from the [docs](https://cran.r-project.org/web/packages/glmnet/glmnet.pdf): "For `family="multinomial"` , [`y`] can be a nc>=2 level factor". – desertnaut Aug 03 '18 at 08:45
  • 1
    @desertnaut Thanks, I stand corrected. – Roland Aug 03 '18 at 08:52
  • @desertnaut, thanks...since RR can be done with multinomial...how do I fix my problem? – Kevin E Dow Aug 03 '18 at 13:14

0 Answers0