ClassificationEP is a module in the HasGP Gaussian Process library. It implements basic Gaussian Process Classification for two classes using the EP approximation. Targets should be +1/-1.
Copyright (C) 2011 Sean Holden. sbh11@cl.cam.ac.uk.
- data EPValue
- type EPConvergenceTest = EPValue -> EPValue -> Bool
- data EPSiteState
- type EPState = (EPSiteState, StdGen, Int)
- type SiteOrder = State EPState [Int]
- generateRandomSiteOrder :: SiteOrder
- generateFixedSiteOrder :: SiteOrder
- gpClassifierEPEvidence :: CovarianceMatrix -> Targets -> DMatrix -> EPSiteState -> Double
- gpClassifierEPLearn :: CovarianceMatrix -> Targets -> SiteOrder -> EPConvergenceTest -> (EPValue, EPState)
- gpClassifierEPPredict :: CovarianceFunction c => EPSiteState -> Inputs -> Targets -> CovarianceMatrix -> c -> Inputs -> DVector
- gpClassifierEPLogEvidence :: CovarianceFunction c => c -> Inputs -> Targets -> SiteOrder -> EPConvergenceTest -> (Double, DVector)
- gpClassifierEPLogEvidenceList :: CovarianceFunction c => Inputs -> Targets -> c -> SiteOrder -> EPConvergenceTest -> [Double] -> (Double, DVector)
- gpClassifierEPLogEvidenceVec :: CovarianceFunction c => Inputs -> Targets -> c -> SiteOrder -> EPConvergenceTest -> DVector -> (Double, DVector)
Documentation
A convergence test for EP usually depends on the evidence and the number of iterations so far. This allows us to specify completely arbitrary convergence tests.
type EPConvergenceTest = EPValue -> EPValue -> BoolSource
By passing a function with this type we can specify arbitrary convergence tests.
data EPSiteState Source
When updating a single site at a time you keep track of var, tauTilde, mu, nuTilde, TauMinus, and MuMinus.
type EPState = (EPSiteState, StdGen, Int)Source
We hide the state used in performing EP using the state monad. We need to include a random number generator and the number of iterations.
type SiteOrder = State EPState [Int]Source
If we're updating sites in a random order then we need access to the random number generator.
generateRandomSiteOrder :: SiteOrderSource
We're often going to want to update sites in a random order. So we need a state transformer that takes the current state (which includes a random number generator) and produces a random permutation.
generateFixedSiteOrder :: SiteOrderSource
For completeness: just in case you want to update sites in a non-random manner, this state transformer does exactly that.
:: CovarianceMatrix | |
-> Targets | |
-> DMatrix | L matrix |
-> EPSiteState | |
-> Double | log marginal likelihood. |
Compute the approximation to the log marginal likelihood.
gpClassifierEPLearn :: CovarianceMatrix -> Targets -> SiteOrder -> EPConvergenceTest -> (EPValue, EPState)Source
The learning algorithm. Takes an arbitrary function for convergence testing.
:: CovarianceFunction c | |
=> EPSiteState | |
-> Inputs | |
-> Targets | Inputs in training set |
-> CovarianceMatrix | |
-> c | Covariance Function |
-> Inputs | New inputs |
-> DVector |
Prediction with GP classifiers based on EP learning. Takes a matrix in which each row is an example to be classified.
gpClassifierEPLogEvidenceSource
:: CovarianceFunction c | |
=> c | Covariance |
-> Inputs | |
-> Targets | |
-> SiteOrder | |
-> EPConvergenceTest | |
-> (Double, DVector) |
Compute the log evidence and its first derivative for the EP approximation for GP classification. Targets should be +1/-1. Outputs the -log marginal likelihood and a vector of its derivatives.
gpClassifierEPLogEvidenceListSource
:: CovarianceFunction c | |
=> Inputs | |
-> Targets | |
-> c | Covariance |
-> SiteOrder | |
-> EPConvergenceTest | |
-> [Double] | |
-> (Double, DVector) |
Essentially the same as gpClassifierEPLogEvidence, but makes a covariance function using the hyperparameters supplied in a list and passes it on.
gpClassifierEPLogEvidenceVecSource
:: CovarianceFunction c | |
=> Inputs | |
-> Targets | |
-> c | Covariance |
-> SiteOrder | |
-> EPConvergenceTest | |
-> DVector | |
-> (Double, DVector) |
Essentially the same as gpClassifierEPLogEvidence, but makes a covariance function using the hyperparameters supplied in a vector and passes it on.