Skip to content

Commit d9186ca

Browse files
committed
adding basic docstrings for solvers
1 parent ba0c224 commit d9186ca

File tree

2 files changed

+73
-1
lines changed

2 files changed

+73
-1
lines changed

src/fit/solvers.jl

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,69 @@ abstract type Solver end
1616

1717
# ===================== analytical.jl
1818

19+
"""
20+
$SIGNATURES
21+
22+
Analytical solver (Cholesky). If the `iterative` parameter is set to `true`
23+
then a CG solver is used. The CG solver is matrix-free and should be preferred
24+
in "large scale" cases (when the hat matrix `X'X` is "big").
25+
26+
## Parameters
27+
28+
* `iterative` (Bool): whether to use CG (iterative) or not
29+
* `max_inner` (Int): in the iterative mode, how many inner iterations to do.
30+
"""
1931
@with_kw struct Analytical <: Solver
2032
iterative::Bool = false
2133
max_inner::Int = 200
2234
end
23-
2435
CG() = Analytical(; iterative=true)
2536

2637
# ===================== newton.jl
2738

39+
"""
40+
$SIGNATURES
41+
42+
Newton solver. This is a full Hessian solver and should be avoided for
43+
"large scale" cases.
44+
"""
2845
struct Newton <: Solver end
2946

47+
"""
48+
$SIGNATURES
49+
50+
Newton CG solver. This is the same as the Newton solver except that instead
51+
of solving systems of the form `H\\b` where `H` is the full Hessian, it uses
52+
a matrix-free conjugate gradient approach to solving that system. This should
53+
generally be preferred for larger scale cases.
54+
"""
3055
struct NewtonCG <: Solver end
3156

57+
"""
58+
$SIGNATURES
59+
60+
LBFGS quasi-Newton solver. See [the wikipedia entry](https://en.wikipedia.org/wiki/Limited-memory_BFGS).
61+
"""
3262
struct LBFGS <: Solver end
3363

3464
# struct BFGS <: Solver end
3565

3666
# ===================== pgrad.jl
3767

68+
"""
69+
$SIGNATURES
70+
71+
Proximal Gradient solver for non-smooth objective functions.
72+
73+
## Parameters
74+
75+
* `accel` (Bool): whether to use Nesterov-style acceleration
76+
* `max_iter` (Int): number of overall iterations
77+
* `tol` (Float64): tolerance for the relative change θ ie `norm(θ-θ_)/norm(θ)`
78+
* `max_inner`: number of inner steps when searching for a stepsize in the
79+
backtracking step
80+
* `beta`: rate of shrinkage in the backtracking step (between 0 and 1)
81+
"""
3882
@with_kw struct ProxGrad <: Solver
3983
accel::Bool = false # use Nesterov style acceleration (see also FISTA)
4084
max_iter::Int = 1000 # max number of overall iterations
@@ -48,6 +92,21 @@ ISTA(; kwa...) = ProxGrad(;accel = false, kwa...)
4892

4993
# ===================== iwls.jl
5094

95+
"""
96+
$SIGNATURES
97+
98+
Iteratively Reweighted Least Square with Conjugate Gradient. This is the
99+
standard (expensive) IWLS but with more efficient solves to avoid full matrix
100+
computations.
101+
102+
## Parameters
103+
104+
* `max_iter` (Int): number of max iterations (outer)
105+
* `max_inner` (Int): number of iterations for the CG solves
106+
* `tol` (Float64): tolerance for the relative change θ ie `norm(θ-θ_)/norm(θ)`
107+
* `damping` (Float64): how much to trust iterates (1=full trust)
108+
* `threshold` (Float64): threshold for the residuals
109+
"""
51110
@with_kw struct IWLSCG <: Solver
52111
max_iter::Int = 100
53112
max_inner::Int = 200

src/mlj/regressors.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22
LINEAR REGRESSOR (OLS)
33
====================== =#
44

5+
"""
6+
$SIGNATURES
7+
8+
Standard linear regression model.
9+
10+
## Parameters
11+
12+
* `fit_intercept` (Bool): whether to fit the intercept or not.
13+
* `solver`: type of solver to use (if `nothing` the default is used). The
14+
solver is Cholesky by default but can be Conjugate-Gradient as
15+
well. See `?Analytical` for more information.
16+
17+
"""
518
@with_kw_noshow mutable struct LinearRegressor <: MMI.Deterministic
619
fit_intercept::Bool = true
720
solver::Option{Solver} = nothing

0 commit comments

Comments
 (0)