ACEfit
Documentation for ACEfit.
Scikit-learn solvers
To use Python based Scikit-learn solvers you need to load PythonCall in addition to ACEfit.
using ACEfit
using PythonCall
MLJ solvers
To use MLJ solvers you need to load MLJ in addition to ACEfit
using ACEfit
using MLJ
After that you need to load an appropriate MLJ solver. Take a look on available MLJ solvers. Note that only MLJScikitLearnInterface.jl and MLJLinearModels.jl have extension available. To use other MLJ solvers please file an issue.
You need to load the solver and then create a solver structure
# Load ARD solver
ARDRegressor = @load ARDRegressor pkg=MLJScikitLearnInterface
# Create the solver itself and give it parameters
solver = ARDRegressor(
max_iter = 300,
tol = 1e-3,
threshold_lambda = 10000
)
After this you can use the MLJ solver like any other solver.
Index
ACEfit.ASP
ACEfit.AbstractData
ACEfit.BLR
ACEfit.LSQR
ACEfit.QR
ACEfit.RRQR
ACEfit.SKLEARN_ARD
ACEfit.SKLEARN_BRR
ACEfit.TruncatedSVD
ACEfit.assemble
ACEfit.assemble_weights
ACEfit.basis_size
ACEfit.count_observations
ACEfit.feature_matrix
ACEfit.target_vector
ACEfit.weight_vector
ACEfit.ASP
— TypeASP
: Active Set Pursuit solver
Solves the lasso optimization problem.
\[\max_{y} \left( b^T y - \frac{1}{2} λ y^T y \right)\]
subject to
\[ \|A^T y\|_{\infty} \leq 1.\]
Constructor Keyword arguments
ACEfit.ASP(; P = I, select = (:byerror, 1.0), tsvd = false, nstore=100,
params...)
select
: Selection criterion for the final solution (required):final
: final solution (largest computed basis)(:byerror, q)
: solution with error withinq
times the minimum error along the path; if training error is used andq == 1.0
, then this is equivalent to to:final
.(:bysize, n)
: best solution with at mostn
non-zero features; if training error is used, then it will be the solution with exactlyn
non-zero features.
P = I
: prior / regularizer (optional)
The remaining kwarguments to ASP
are parameters for the ASP homotopy solver.
actMax
: Maximum number of active constraints.min_lambda
: Minimum value forλ
. (defaults to 0)loglevel
: Logging level.itnMax
: Maximum number of iterations.
Extended syntax for solve
solve(solver::ASP, A, y, Aval=A, yval=y)
A
:m
-by-n
design matrix. (required)b
:m
-vector. (required)Aval = nothing
:p
-by-n
validation matrixbval = nothing
:p
- validation vector
If independent Aval
and yval
are provided (instead of detaults A, y
), then the solver will use this separate validation set instead of the training set to select the best solution along the model path.
ACEfit.AbstractData
— TypeACEfit users should define a type of the form: UserData <: AbstractData
Several functions acting on such a type should be implemented: countobservations featurematrix targetvector weightvector
ACEfit.BLR
— Typestruct BLR
: Bayesian linear regression
Refer to bayesianlinear.jl (for now) for kwarg definitions.
ACEfit.LSQR
— TypeLSQR
ACEfit.QR
— Typestruct QR
: linear least squares solver, using standard QR factorisation; this solver computes
\[ θ = \arg\min \| A \theta - y \|^2 + \lambda \| P \theta \|^2\]
Constructor
ACEfit.QR(; lambda = 0.0, P = nothing)
where
λ
: regularisation parameterP
: right-preconditioner / tychonov operator
ACEfit.RRQR
— Typestruct RRQR
: linear least squares solver, using rank-revealing QR factorisation, which can sometimes be more robust / faster than the standard regularised QR factorisation. This solver first transforms the parameters $\theta_P = P \theta$, then solves
\[ θ = \arg\min \| A P^{-1} \theta_P - y \|^2\]
where the truncation tolerance is given by the rtol
parameter, and finally reverses the transformation. This uses the pqrfact
of LowRankApprox.jl
; For further details see the documentation of LowRankApprox.jl
.
Crucially, note that this algorithm is not deterministic; the results can change slightly between applications.
Constructor
ACEfit.RRQR(; rtol = 1e-15, P = I)
where
rtol
: truncation toleranceP
: right-preconditioner / tychonov operator
ACEfit.SKLEARN_ARD
— TypeSKLEARN_ARD
ACEfit.SKLEARN_BRR
— TypeSKLEARN_BRR
ACEfit.TruncatedSVD
— Typestruct TruncatedSVD
: linear least squares solver for approximately solving
\[ θ = \arg\min \| A \theta - y \|^2 \]
- transform $\tilde\theta = P \theta$
- perform svd on $A P^{-1}$
- truncate svd at
rtol
, i.e. keep only the components for which $\sigma_i \geq {\rm rtol} \max \sigma_i$ - Compute $\tilde\theta$ from via pseudo-inverse
- Reverse transformation $\theta = P^{-1} \tilde\theta$
Constructor
ACEfit.TruncatedSVD(; rtol = 1e-9, P = I)
where
rtol
: relative toleranceP
: right-preconditioner / tychonov operator
ACEfit.assemble
— MethodAssemble feature matrix and target vector for given data and basis.
ACEfit.assemble_weights
— MethodAssemble full weight vector for vector of data elements.
ACEfit.basis_size
— Methodbasis_size(model)
Return the length of the basis, assuming that model
is a linear model, or when interpreted as a linear model. The returned integer must match the size of the feature matrix that will be assembled for the given model.
It defaults to Base.length
but can be overloaded if needed.
ACEfit.count_observations
— MethodReturns the corresponding number of rows in the design matrix.
ACEfit.feature_matrix
— MethodReturns the corresponding design matrix (A) entries.
ACEfit.target_vector
— MethodReturns the corresponding target vector (Y) entries.
ACEfit.weight_vector
— MethodReturns the corresponding weight vector (W) entries.