1

I have 300 data samples with around 4000 dimension feature each. Each input has a 5 dim. output which is in the range of -2 to 2. I am trying to fit a lasso model to it. I went through a few posts which talk about cross validation strategies like this one: Leave one out cross validation algorithm in matlab

But I saw that lasso does not support leaveout in Matlab! http://www.mathworks.com/help/stats/lasso.html

How can I train a model using leave one out cross validation and fit a model using lasso on my dataset? I am trying to do this in matlab. I would like to get a set of weights which I will be able to use for future predictions on other data.

I tried using glmnet: http://www.stanford.edu/~hastie/glmnet_matlab/intro.html but I couldn't compile it on my machine due to lack of proper mex compiler.

Any solutions to my problem? Thanks :)

EDIT

I am also trying to use lasso function in-built with MATLAB. It has an option to perform cross validation. It outputs B and Fit Statistics, where B is Fitted coefficients, a p-by-L matrix, where p is the number of predictors (columns) in X, and L is the number of Lambda values.

Now given a new test sample, how can I calculate the output using this model?

Community
  • 1
  • 1

1 Answers1

1

You can use a leave-one-out approach regardless of your training method. As explained here, you can use crossvalind to split the data into training and test sets.

[Train, Test] = crossvalind('LeaveMOut', N, M)
Community
  • 1
  • 1
buzjwa
  • 2,632
  • 2
  • 24
  • 37
  • Thanks for your answer. I found a code on SO: http://stackoverflow.com/questions/15433666/leave-one-out-cross-validation-algorithm-in-matlab I was looking for something like that actually. Btw could you give me any pointers on this question: http://stats.stackexchange.com/questions/93800/parameter-tuning-in-lars-lasso-matlab – Sharath Chandra Apr 15 '14 at 01:48