I'm writing a code for k-fold cross validation for lasso. But I am stuck at understanding it clearly.
The number of folds that I'm using is 3 (k=3)
I have a matrix X[20x15], I split it into two sets the training and the testing, X_train[13x15] and X_test[7x15] then I generated some data Y_train[13x1] and Y_test[7x1]
Then I generated a coefficient vector by using the training data.
I know that I have to introduce the Y_test and X_test and to compute the mse(mean square error) and this is the part which is not very clear what to do next. I know the mse is calculated using this formula:
I think the Yi will be the Y_train and the will be the X_train, but then do I have to do the same separately with the test data? Or do I have to use somehow the test data in the training?