Y = dlmread('joke.csv');
index = find(Y == 99);
Y(index) = NaN;
Y = Y';
K = correlation(Y);
Ylearn = cofilter(K,Y);

% evaluierung, z.B. indem ein bekannter Wert auf NaN gesetzt wird und
% danach überprüft wird, wie die Vorhersage dafür aussieht
Ytest = Y;
Ytest(1,1) = NaN;
Ktest = correlation(Ytest);
Ytest = cofilter(Ktest,Ytest);
orig = Y(1,1)
class = Ytest(1,1)

% volle evaluation (leave one out)
notNaNIndex = find(~isnan(Y));
diff = []
for i=1:length(notNaNIndex)
    Ytest = Y;
    Ytest(notNaNIndex(i)) = NaN;
    Ktest = correlation(Ytest);
    Ytest = cofilter(Ktest,Ytest);
    orig = Y(notNaNIndex(i));
    class = Ytest(notNaNIndex(i));
    diff = [diff sqrt((orig - class)^2)];
    fprintf('aktueller Fehler: %f\n' , sqrt((orig - class)^2));
    fprintf('aktueller gemittelter Fehler: %f\n\n', sum(diff)/length(diff));
end

fprintf('mittlerer Fehler: %f', sum(diff)/length(diff));