Skip to content

Commit

Permalink
Add lambda output from fully-determined EM bayesian regression
Browse files Browse the repository at this point in the history
  • Loading branch information
batterseapower committed Aug 17, 2008
1 parent d2312e6 commit b10cfae
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Algorithms/MachineLearning/LinearRegression.hs
Expand Up @@ -166,16 +166,17 @@ regressEMBayesianLinearModel initial_alpha initial_beta basis_fns ds
-- training data than there are basis functions you want to assign weights to. Due to the introduction of this -- training data than there are basis functions you want to assign weights to. Due to the introduction of this
-- constraint, it is much faster than the other function and yet produces results of similar quality. -- constraint, it is much faster than the other function and yet produces results of similar quality.
-- --
-- Unlike with 'regressEMBayesianLinearModel', the effective number of parameters, gamma, used by the regressed model -- Like with 'regressEMBayesianLinearModel', the effective number of parameters, gamma, used by the regressed model
-- is not returned because for this function to make sense you need to be sure that there is sufficient data that all -- is returned. However, because for this function to make sense you need to be sure that there is sufficient data
-- the parameters are determined, i.e. gamma = number of basis functions. -- that all the parameters are determined, the returned gamma is always just the number of basis functions (and
-- hence weights).
-- --
-- Equations 3.98 and 3.99 in Bishop. -- Equations 3.98 and 3.99 in Bishop.
regressFullyDeterminedEMBayesianLinearModel regressFullyDeterminedEMBayesianLinearModel
:: (Vectorable input) :: (Vectorable input)
=> Precision -- ^ Initial estimate of Gaussian weight prior => Precision -- ^ Initial estimate of Gaussian weight prior
-> Precision -- ^ Initial estimate for precision of noise on samples -> Precision -- ^ Initial estimate for precision of noise on samples
-> [input -> Target] -> DataSet -> (LinearModel input, BayesianVarianceModel input) -> [input -> Target] -> DataSet -> (LinearModel input, BayesianVarianceModel input, EffectiveNumberOfParameters)
regressFullyDeterminedEMBayesianLinearModel initial_alpha initial_beta basis_fns ds regressFullyDeterminedEMBayesianLinearModel initial_alpha initial_beta basis_fns ds
= loop initial_alpha initial_beta eps False = loop initial_alpha initial_beta eps False
where where
Expand All @@ -186,7 +187,7 @@ regressFullyDeterminedEMBayesianLinearModel initial_alpha initial_beta basis_fns


-- I'm not very happy about all the duplicate code around here.. is there a better way, without too much extra ugliness? -- I'm not very happy about all the duplicate code around here.. is there a better way, without too much extra ugliness?
loop alpha beta threshold done loop alpha beta threshold done
| done = (linear_model, BayesianVarianceModel { bvm_basis_fns = basis_fns, bvm_weight_covariance = weight_covariance, bvm_beta = beta }) | done = (linear_model, BayesianVarianceModel { bvm_basis_fns = basis_fns, bvm_weight_covariance = weight_covariance, bvm_beta = beta }, m)
| otherwise = loop alpha' beta' (threshold * 2) (eqWithin threshold alpha alpha' && eqWithin threshold beta beta') | otherwise = loop alpha' beta' (threshold * 2) (eqWithin threshold alpha alpha' && eqWithin threshold beta beta')
where where
(weights, weight_covariance) = bayesianPosteriorParameters alpha beta design_matrix (ds_targets ds) (weights, weight_covariance) = bayesianPosteriorParameters alpha beta design_matrix (ds_targets ds)
Expand Down

0 comments on commit b10cfae

Please sign in to comment.