/gpml-matlab/gpml/binaryEPGP.m

http://pmtksupport.googlecode.com/ · MATLAB · 53 lines · 8 code · 4 blank · 41 comment · 1 complexity · fde85523f7a381a19094c25eafee56f9 MD5 · raw file

  1. function varargout = binaryEPGP(hyper, covfunc, varargin)
  2. % binaryEPGP - The Expectation Propagation approximation for binary Gaussian
  3. % process classification. Two modes are possible: training or testing: if no
  4. % test cases are supplied, then the approximate negative log marginal
  5. % likelihood and its partial derivatives wrt the hyperparameters is computed;
  6. % this mode is used to fit the hyperparameters. If test cases are given, then
  7. % the test set predictive probabilities are returned. The program is flexible
  8. % in allowing a multitude of covariance functions.
  9. %
  10. % usage: [nlZ, dnlZ ] = binaryEPGP(hyper, covfunc, x, y);
  11. % or: [p, mu, s2, nlZ] = binaryEPGP(hyper, covfunc, x, y, xstar);
  12. %
  13. % where:
  14. %
  15. % hyper is a (column) vector of hyperparameters
  16. % covfunc is the name of the covariance function (see below)
  17. % lik is the name of the likelihood function (see below)
  18. % x is a n by D matrix of training inputs
  19. % y is a (column) vector (of size n) of binary +1/-1 targets
  20. % xstar is a nn by D matrix of test inputs
  21. % nlZ is the returned value of the negative log marginal likelihood
  22. % dnlZ is a (column) vector of partial derivatives of the negative
  23. % log marginal likelihood wrt each log hyperparameter
  24. % p is a (column) vector (of length nn) of predictive probabilities
  25. % mu is a (column) vector (of length nn) of predictive latent means
  26. % s2 is a (column) vector (of length nn) of predictive latent variances
  27. %
  28. % The length of the vector of hyperparameters depends on the covariance
  29. % function, as specified by the "covfunc" input to the function, specifying the
  30. % name of a covariance function. A number of different covariance function are
  31. % implemented, and it is not difficult to add new ones. See "help covFunctions"
  32. % for the details
  33. %
  34. % The function can conveniently be used with the "minimize" function to train
  35. % a Gaussian process, eg:
  36. %
  37. % [hyper, fX, i] = minimize(hyper, 'binaryEPGP', length, 'covSEiso',
  38. % 'logistic', x, y);
  39. %
  40. % Copyright (c) 2004, 2005, 2006, 2007 Carl Edward Rasmussen, 2007-02-19.
  41. if nargin<4 || nargin>5
  42. disp('Usage: [nlZ, dnlZ ] = binaryEPGP(hyper, covfunc, x, y);')
  43. disp(' or: [p, mu, s2, nlZ] = binaryEPGP(hyper, covfunc, x, y, xstar);')
  44. return
  45. end
  46. % Note, this function is just a wrapper provided for backward compatibility,
  47. % the functionality is now provided by the more general binaryGP function.
  48. varargout = cell(nargout, 1); % allocate the right number of output arguments
  49. [varargout{:}] = binaryGP(hyper, 'approxEP', covfunc, 'cumGauss', varargin{:});