Skip to content

Commit bd9d915

Browse files
committed
Merge branch 'dev'
2 parents 30f7a30 + 3a2d613 commit bd9d915

File tree

7 files changed

+56
-22
lines changed

7 files changed

+56
-22
lines changed

Project.toml

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MLJLinearModels"
22
uuid = "6ee0df7b-362f-4a72-a706-9e79364fb692"
33
authors = ["Thibaut Lienart <[email protected]>"]
4-
version = "0.8.1"
4+
version = "0.9.0"
55

66
[deps]
77
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
@@ -19,20 +19,4 @@ LinearMaps = "2.6, 3.2"
1919
MLJModelInterface = "0.3, 0.4, 1.0"
2020
Optim = "0.20, 0.21, 1"
2121
Parameters = "0.12"
22-
julia = "1.6"
23-
24-
[extras]
25-
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
26-
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
27-
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
28-
MLJ = "add582a8-e3ab-11e8-2d5e-e98b27df1bc7"
29-
MLJBase = "a7f614a8-145f-11e9-1d2a-a57a1082229d"
30-
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
31-
RCall = "6f49c342-dc21-5d91-9882-a32aef131414"
32-
RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b"
33-
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
34-
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
35-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
36-
37-
[targets]
38-
test = ["DelimitedFiles", "PyCall", "ForwardDiff", "Test", "Random", "RDatasets", "RCall", "MLJ", "MLJBase", "StableRNGs", "DataFrames"]
22+
julia = "1.6, 1"

docs/src/quickstart.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,28 @@ ypred = predict_mode(mach, rows=1:2)
150150
```
151151

152152
Which, in my case, gives `setosa`, `setosa` (correct in both cases).
153+
154+
### Customizing the solvers
155+
156+
Depending on your data you may want to customize the default solver associated with your model. Since this package uses [Optim](https://julianlsolvers.github.io/Optim.jl/stable/) behind the scene, we can interact directly with this package.
157+
158+
For instance, you may need to be more stringent about the convergence criterion of the LBFGS solver. This can be done by changing the general Optim `f_tol` parameter which defaults to ``10^{-4}``:
159+
160+
```julia
161+
import Optim
162+
163+
new_optim_options = Optim.Options(f_tol=1e-6)
164+
mdl = MultinomialClassifier(solver=LBFGS(optim_options=new_optim_options))
165+
mach = machine(mdl, X, y)
166+
fit!(mach)
167+
```
168+
169+
You could also just try another solver:
170+
171+
```julia
172+
mdl = MultinomialClassifier(solver=NewtonCG(optim_options=new_optim_options))
173+
mach = machine(mdl, X, y)
174+
fit!(mach)
175+
```
176+
177+
For a full description of available solvers and API, see: [Solvers](@ref).

src/fit/solvers.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ solver = MLJLinearModels.Newton(optim_options = Optim.Options(time_limit = 20),
5454
```
5555
"""
5656
@with_kw struct Newton{O,S} <: Solver
57-
optim_options::O = Optim.Options()
57+
optim_options::O = Optim.Options(f_tol=1e-4)
5858
newton_options::S = (; )
5959
end
6060

@@ -79,7 +79,7 @@ solver = MLJLinearModels.Newton(optim_options = Optim.Options(time_limit = 20),
7979
8080
"""
8181
@with_kw struct NewtonCG{O,S} <: Solver
82-
optim_options::O = Optim.Options()
82+
optim_options::O = Optim.Options(f_tol=1e-4)
8383
newtoncg_options::S = (; )
8484
end
8585

@@ -100,7 +100,7 @@ solver = MLJLinearModels.Newton(optim_options = Optim.Options(time_limit = 20),
100100
```
101101
"""
102102
@with_kw struct LBFGS{O,S} <: Solver
103-
optim_options::O = Optim.Options()
103+
optim_options::O = Optim.Options(f_tol=1e-4)
104104
lbfgs_options::S = (; )
105105
end
106106

test/Project.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[deps]
2+
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
3+
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
4+
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
5+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
6+
MLJ = "add582a8-e3ab-11e8-2d5e-e98b27df1bc7"
7+
MLJBase = "a7f614a8-145f-11e9-1d2a-a57a1082229d"
8+
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
9+
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
10+
RCall = "6f49c342-dc21-5d91-9882-a32aef131414"
11+
RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b"
12+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
13+
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
14+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
15+
16+
[compat]
17+
DataFrames = "1.4"
18+
ForwardDiff = "0.10"
19+
MLJ = "0.19"
20+
MLJBase = "0.21"
21+
PyCall = "1.95"
22+
RCall = "0.13"
23+
RDatasets = "0.7"
24+
StableRNGs = "1.0"

test/docs/Project.toml

Whitespace-only changes.

test/fit/robust.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ end
7878
@test isapprox(J(θ1), 7.359476, rtol=1e-5)
7979
@test isapprox(J(θ_newton), 0.486388, rtol=1e-5)
8080
@test isapprox(J(θ_newtoncg), 0.486388, rtol=1e-5)
81-
@test isapprox(J(θ_lbfgs), 0.486388, rtol=1e-5)
81+
@test isapprox(J(θ_lbfgs), 0.486788, rtol=1e-5)
8282
@test isapprox(J(θ_iwls), 0.486388, rtol=1e-5)
8383
end
8484

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using MLJLinearModels, Test, LinearAlgebra
22
using Random, StableRNGs, DataFrames, ForwardDiff
3+
import Optim
34
import MLJ, MLJBase
45

56
DO_COMPARISONS = false; include("testutils.jl")

0 commit comments

Comments
 (0)