Skip to content

Commit 1c073fe

Browse files
fix doctests and other minor docs changes
1 parent 4f3c49f commit 1c073fe

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

src/maxnet_function.jl

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ end
2424
"""
2525
maxnet(
2626
presences, predictors;
27-
[features],
28-
regularization_multiplier, regularization_function,
27+
features, regularization_multiplier, regularization_function,
2928
addsamplestobackground, weight_factor, backend,
3029
kw...
3130
)
3231
32+
Fit a model using the maxnet algorithm.
33+
3334
# Arguments
3435
- `presences`: A `BitVector` where presences are `true` and background samples are `false`
3536
- `predictors`: A Tables.jl-compatible table of predictors. Categorical predictors should be `CategoricalVector`s
3637
3738
# Keywords
38-
- `features`: Either:
39-
- A `Vector` of `AbstractFeatureClass` type features; or
40-
- A `String` where "l" = linear and categorical, "q" = quadratic, "p" = product, "t" = threshold, "h" = hinge (e.g. "lqh"); or
41-
- The default, in which case the features are based on the number of presences are used. See [`default_features`](@ref)
39+
- `features`: Either a `Vector` of `AbstractFeatureClass` to be used in the model,
40+
or a `String` where "l" = linear and categorical, "q" = quadratic, "p" = product, "t" = threshold, "h" = hinge (e.g. "lqh"); or
41+
By default, the features are based on the number of presences are used. See [`default_features`](@ref)
4242
- `regularization_multiplier`: A constant to adjust regularization, where a higher `regularization_multiplier` results in a higher penalization for features
4343
- `regularization_function`: A function to compute a regularization for each feature. A default `regularization_function` is built in.
4444
- `addsamplestobackground`: A boolean, where `true` adds the background samples to the predictors. Defaults to `true`.
@@ -53,10 +53,18 @@ Lasso.jl is written in pure julia, but can be slower with large model matrices (
5353
5454
# Examples
5555
```jldoctest
56-
using Maxnet
57-
p_a, env = Maxnet.bradypus()
56+
using Maxnet
57+
p_a, env = Maxnet.bradypus()
58+
59+
bradypus_model = maxnet(p_a, env; features = "lq", backend = GLMNetBackend())
60+
61+
# output
5862
59-
bradypus_model = maxnet(p_a, env; features = "lq", backend = GLMNetBackend());
63+
Fit Maxnet model
64+
Features classes: Maxnet.AbstractFeatureClass[LinearFeature(), CategoricalFeature(), QuadraticFeature()]
65+
Entropy: 6.114650341746531
66+
Model complexity: 21
67+
Variables selected: [:frs6190_ann, :h_dem, :pre6190_l1, :pre6190_l10, :pre6190_l4, :pre6190_l7, :tmn6190_ann, :vap6190_ann, :ecoreg, :cld6190_ann, :dtr6190_ann, :tmx6190_ann]
6068
```
6169
6270
"""

src/mlj_interface.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,18 @@ end
3030
3131
Use `MaxnetBinaryClassifier()` to create an instance with default parameters, or use keyword arguments to specify parameters.
3232
33-
The `link` and `clamp` keywords are passed to `predict`. All other keywords are passed to `maxnet` when te model is fit.
33+
All keywords are passed to `maxnet` when calling `fit!` on a machine of this model type.
3434
See the documentation of [`maxnet`](@ref) for the parameters and their defaults.
3535
36-
# Examples
36+
# Example
3737
```jldoctest
3838
using Maxnet, MLJBase
3939
p_a, env = Maxnet.bradypus()
4040
4141
mach = machine(MaxnetBinaryClassifier(features = "lqp"), env, categorical(p_a))
4242
fit!(mach)
4343
yhat = MLJBase.predict(mach, env)
44+
# output
4445
```
4546
4647
"""
@@ -80,7 +81,8 @@ function MMI.fit(m::MaxnetBinaryClassifier, verbosity::Int, X, y)
8081
return (fitresult, decode), cache, report
8182
end
8283

83-
function MMI.predict(m::MaxnetBinaryClassifier, (fitresult, decode), Xnew)
84-
p = predict(fitresult, Xnew; link = m.link, clamp = m.clamp)
84+
function MMI.predict(m::MaxnetBinaryClassifier, (fitresult, decode), Xnew;
85+
link = Cloglog(), clamp = false)
86+
p = predict(fitresult, Xnew; link = link, clamp = clamp)
8587
MMI.UnivariateFinite(decode, [1 .- p, p])
8688
end

src/predict.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""
22
predict(m, x; link, clamp)
33
4+
Use a maxnet model to predict on new data.
5+
46
# Arguments
57
- `m`: a MaxnetModel as returned by `maxnet`
68
- `x`: a `Tables.jl`-compatible table of predictors. All columns that were used to fit `m` should be present in `x`

0 commit comments

Comments
 (0)