Yp = ccl_learnp_pred_lwlinear(X,model) Locally weighted model prediction Input: X State inputs model Model parameters Ouput: Yp Prediction
0001 function Yp = ccl_learnp_pred_lwlinear(X,model) 0002 % Yp = ccl_learnp_pred_lwlinear(X,model) 0003 % 0004 % Locally weighted model prediction 0005 % 0006 % Input: 0007 % 0008 % X State inputs 0009 % model Model parameters 0010 % 0011 % Ouput: 0012 % 0013 % Yp Prediction 0014 0015 0016 0017 0018 % CCL: A MATLAB library for Constraint Consistent Learning 0019 % Copyright (C) 2007 Matthew Howard 0020 % Contact: matthew.j.howard@kcl.ac.uk 0021 % 0022 % This library is free software; you can redistribute it and/or 0023 % modify it under the terms of the GNU Lesser General Public 0024 % License as published by the Free Software Foundation; either 0025 % version 2.1 of the License, or (at your option) any later version. 0026 % 0027 % This library is distributed in the hope that it will be useful, 0028 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0029 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0030 % Lesser General Public License for more details. 0031 % 0032 % You should have received a copy of the GNU Library General Public 0033 % License along with this library; if not, write to the Free 0034 % Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 0035 0036 N = size(X,2); % get no. data points 0037 0038 % find feature vectors 0039 Phi = model.phi(X); 0040 dimPhi = size(Phi,1); 0041 0042 % find weights 0043 W = model.W(X); 0044 Nc = size(W,1); % get no. data points, dimensionality 0045 0046 % predict training data 0047 for nc=1:Nc 0048 Yp(:,:,nc)=((repmat(W(nc,:),dimPhi,1).*Phi)'*model.w(:,:,nc))'; 0049 %Yp(:,:,nc) = sum(repmat(model.w(:,:,nc),1,N).*Phi).*W(nc,:); 0050 end 0051 Yp = sum(Yp,3)./repmat(sum(W,1),size(Yp,1),1); 0052