Demo entry 6154260

Ridge regression

   

Submitted by anonymous on Oct 04, 2016 at 04:06
Language: Matlab. Code size: 464 Bytes.

%% 2.1 Compute ridge regression
DataFile=importdata('prostate.data.txt','\t');
TrainData=DataFile.data(1:50,:);

k=10.^(-2:0.01:4); % Set multiple penalized parameters
NumOfk=length(k);
w=zeros(8,NumOfk);
w0=zeros(1,NumOfk);

for i=1:NumOfk
    [w(:,i),w0(i)]=RidgeCompute(TrainData(:,1:8),TrainData(:,9),k(i));
end

%% 2.2 Plot Regression Path
figure;
semilogx(k,w);
grid on
xlabel('\delta^2');
ylabel('\theta');
legend(DataFile.textdata(1:8));

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).