Skip to content

Instantly share code, notes, and snippets.

@dgonzo
Created October 16, 2014 02:55
Show Gist options
  • Select an option

  • Save dgonzo/85fdf588e2b7ce8cf3b7 to your computer and use it in GitHub Desktop.

Select an option

Save dgonzo/85fdf588e2b7ce8cf3b7 to your computer and use it in GitHub Desktop.
15minHeadphones
context_map=csvread('train_X_final.csv'); % Load train input (context matrix)
sim_yield_die_loss=csvread('train_Y_final.csv'); % Load train output
wafer_count=size(context_map,1); % Get number of wafers
%Build regular WLSR model +++++++++++++++++++++++++++++++++++++++++++++++++
lambda=0.4; %Decay rate on learning
w_diag=fliplr(lambda.^(1:wafer_count));
W=zeros(wafer_count);
for g=1:wafer_count
W(g,g)=w_diag(g);
end
beta_WLSR=pinv(context_map'*W*context_map)*context_map'*W*sim_yield_die_loss';
context_map_val=csvread('val_X_final.csv'); %Load train input (context matrix)
%Evaluate models
yp_WLSR=context_map_val*beta_WLSR;
%Make sure to cap crazy results outside possible die >600 <0
yp_WLSR(yp_WLSR<0)=0;
yp_WLSR(yp_WLSR>600)=600;
%Now write out prediction
csvwrite('WLSR_prediction_04.csv',yp_WLSR)
%Now calc and write out cost
Y_val=csvread('testing/val_Y.csv');
Y_pred=csvread('WLSR_prediction_04.csv');
err=Y_pred-Y_val;
err_over=sum(abs(err(err>=0)));
err_under=sum(abs(err(err<0)))*10;
overall_score_LSR=(err_under+err_over)/wafer_count;
overall_score_LSR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment