function model = update_multiclass_gp(modelOld, kss, ksNewSample, newLabel) % Update a multi-class GP model % % function model = update_multiclass_gp(modelOld, kss, ksNewSample, newLabel) % % INPUT: modelOld -- the old gp-multiclass model (relevant: noise, L, y) % kss -- self similarity of new example % ksNewSample -- kernel values between new and old training examples % newLabel -- label of new example % Copyright (c) by Alexander Freytag, 2013-11-13. %% % Cholesky update to include the selected sample l = modelOld.L\ksNewSample; lss = sqrt(kss+modelOld.noise-l'*l); L = [modelOld.L, zeros(length(l),1); l', lss ]; %obtain new labels in a single vector newLabels = [modelOld.y, newLabel]; % copy all relevant data model.noise = modelOld.noise; % store relevant new data model.L = L; % obtain unique class labels (length of this vector equals the number of classes) % Note: we can not re-use the previously known labels, since newLabel % might contain a completely new class model.unique_labels = unique(newLabels); % loop over classes and thus over binary one-vs-all tasks for k=1:length(model.unique_labels) % binary label vector for each binary task current_labels = 2*(newLabels==model.unique_labels(k))-1; % precompute and store alpha vector for each binary task model.alpha{k} = L'\(L\current_labels'); end model.y = newLabels; end