function RS=RSquared(y_true,y_pred)

s1=0;
s2=0;
for i=1:length(y_true)
    s1=s1+power(y_true(i)-y_pred(i),2);
    s2=s2+power(y_true(i)-mean(y_true),2);
end
RS=1-s1/s2;