main.m893 chars30 lines
In this function, we first compute the number of training and test samples using the length function. We initialize the output variable out as a zero vector with length equal to the number of test samples. We then loop over each value of m, where m is the number of training samples to be used for learning. For each value of m, we extract the first m samples from the training data and compute the weight vector w using the closed-form solution. We then predict the target values for the test data and compute the corresponding MSE value using the sum-square error formula. Finally, we store this value in the out vector. The function returns the out vector which contains the empirical MSE test loss for each value of m.
gistlibby LogSnag