Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exception for committees without SVD. #76

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/bayesianlinear.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Perform Bayesian linear regression, possibly with automatic relevance determinat

### output settings
- `verbose::Bool = true`
- `committee_size::Int = 0`: if nonzero, sample from the posterior and include a committee in the results.
- `committee_size::Int = 0`: if nonzero, sample from the posterior and include a committee in the results (presently, `factorization = :svd` required for committees)
- `ret_covar::Bool = false`: whether to supply the covariance matrix in the results.

### solver settings
Expand All @@ -203,6 +203,11 @@ function bayesian_linear_regression(A, Y;
optimizer = :LBFGS,
tol::AbstractFloat = 1e-3,
max_iter::Int = 1000)

if (committee_size>0 && factorization != :svd)
error("At present, only the SVD factorization can produce committees.")
end

if (ard_threshold == 0.0) && (factorization == :cholesky)
return bayesian_fit(A, Y;
variance_c_floor = sig_0_floor * sig_0_floor,
Expand Down
4 changes: 4 additions & 0 deletions test/test_bayesianlinear.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ACEfit
using ACEfit.BayesianLinear
using LinearAlgebra
using Test

Expand All @@ -23,3 +24,6 @@ for n in 1:committee_size
end
covar_approx .= covar_approx / committee_size
@test maximum(abs.(covar_approx - covar)) < 0.01

@info("Test error from invalid committee request.")
@test_throws ErrorException("At present, only the SVD factorization can produce committees.") BayesianLinear.bayesian_linear_regression(X, Y; committee_size=committee_size, factorization=:cholesky)
Loading