Skip to content

Commit 60f4501

Browse files
docs (#15)
add docs
1 parent 01a729c commit 60f4501

File tree

6 files changed

+148
-11
lines changed

6 files changed

+148
-11
lines changed

README.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1-
# maxnet
2-
This is a pure Julia implementation of the [maxnet algorithm](https://github.com/mrmaxent/maxnet).
3-
4-
Maxnet is closely related to the java MaxEnt application, which is widely used in species distribution modelling. It was developped by Steven Philips. Please see [this publication](https://doi.org/10.1111/ecog.03049) for more details about the maxnet algorithm.
5-
6-
Also see the Maxent page on the site of the [American Museum for Natural History](https://biodiversityinformatics.amnh.org/open_source/maxent/)
1+
# Maxnet
72

83
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://tiemvanderdeure.github.io/Maxnet.jl/stable/)
94
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://tiemvanderdeure.github.io/Maxnet.jl/dev/)
105
[![Build Status](https://github.com/tiemvanderdeure/Maxnet.jl/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/tiemvanderdeure/Maxnet.jl/actions/workflows/CI.yml?query=branch%3Amaster)
116
[![Coverage](https://codecov.io/gh/tiemvanderdeure/Maxnet.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/tiemvanderdeure/Maxnet.jl)
7+
8+
This is a Julia implementation of the [maxnet algorithm](https://github.com/mrmaxent/maxnet), with all core functionality in the original R package.
9+
10+
Maxnet transforms input data in various ways and then uses the GLMnet algorithm to fit a lasso path, selecting the best variables and transformations.
11+
12+
Maxnet is closely related to the Java MaxEnt application, which is widely used in species distribution modelling. Maxnet was introduced in [this publication](https://doi.org/10.1111/ecog.03049), which goes more into details about the algorithm.
13+
14+
Also see the Maxent page on the site of the [American Museum for Natural History](https://biodiversityinformatics.amnh.org/open_source/maxent/).
15+
16+
A basic example, using a toy dataset included in the package:
17+
```julia
18+
using Maxnet
19+
p_a, env = Maxnet.bradypus()
20+
bradypus_model = maxnet(p_a, env)
21+
prediction = predict(bradypus_model, env)
22+
```
23+
24+
Maxnet integrates with [MLJ](https://github.com/alan-turing-institute/MLJ.jl) through the `MaxnetBinaryClassifier` type.

docs/make.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ makedocs(;
1111
format=Documenter.HTML(;
1212
prettyurls=get(ENV, "CI", "false") == "true",
1313
canonical="https://tiemvanderdeure.github.io/Maxnet.jl",
14-
edit_link="master",
1514
assets=String[],
1615
),
1716
pages=[
1817
"Home" => "index.md",
18+
"Usage" => Any[
19+
"Quick start" => "usage/quickstart.md",
20+
"MLJ" => "usage/mlj.md",
21+
],
22+
"API reference" => "reference/api.md"
1923
],
2024
)
2125

docs/src/index.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@ CurrentModule = Maxnet
33
```
44

55
# Maxnet
6+
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://tiemvanderdeure.github.io/Maxnet.jl/stable/)
7+
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://tiemvanderdeure.github.io/Maxnet.jl/dev/)
8+
[![Build Status](https://github.com/tiemvanderdeure/Maxnet.jl/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/tiemvanderdeure/Maxnet.jl/actions/workflows/CI.yml?query=branch%3Amaster)
9+
[![Coverage](https://codecov.io/gh/tiemvanderdeure/Maxnet.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/tiemvanderdeure/Maxnet.jl)
10+
11+
12+
This is a Julia implementation of the [maxnet algorithm](https://github.com/mrmaxent/maxnet), with all core functionality in the original R package.
13+
14+
Maxnet transforms input data in various ways and then uses the GLMnet algorithm to fit a lasso path, selecting the best variables and transformations.
15+
16+
Maxnet is closely related to the Java MaxEnt application, which is widely used in species distribution modelling. It was developped by Steven Philips. See [this publication](https://doi.org/10.1111/ecog.03049) for more details about maxnet.
17+
18+
Also see the Maxent page on the site of the [American Museum for Natural History](https://biodiversityinformatics.amnh.org/open_source/maxent/).
619

720
Documentation for [Maxnet](https://github.com/tiemvanderdeure/Maxnet.jl).
821

922
```@index
1023
```
11-
12-
```@autodocs
13-
Modules = [Maxnet]
14-
```

docs/src/reference/api.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
```@meta
2+
CurrentModule = Maxnet
3+
```
4+
5+
# API
6+
7+
## Index
8+
```@index
9+
```
10+
11+
## Functions
12+
```@autodocs
13+
Modules = [Maxnet]
14+
Order = [:function]
15+
```
16+
17+
## Types
18+
```@autodocs
19+
Modules = [Maxnet]
20+
Order = [:type]
21+
```
22+

docs/src/usage/mlj.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
```@meta
2+
CurrentModule = Maxnet
3+
```
4+
5+
# Integration with MLJ
6+
Maxnet.jl integrates with the MLJ ecosystem.
7+
8+
See [MLJs project page](https://github.com/alan-turing-institute/MLJ.jl) for more info about MLJ.
9+
10+
To use Maxnet with MLJ, initialise a model by calling [`MaxnetBinaryClassifier`](@ref), which accepts any arguments otherwise passed to [`maxnet`]. The model can then be used to construct MLJ's `machine`.
11+
12+
For example:
13+
14+
```julia
15+
using Maxnet: MaxnetBinaryClassifier, bradypus
16+
using MLJBase
17+
using CategoricalArrays
18+
19+
# sample data
20+
y, X = bradypus()
21+
22+
# define a model
23+
model = MaxnetBinaryClassifier(features = "lq")
24+
25+
# construct a machine
26+
mach = machine(model, X, categorical(y))
27+
28+
# partition data
29+
train, test = partition(eachindex(y), 0.7, shuffle=true)
30+
31+
# fit the machine to the data
32+
fit!(mach; rows = train)
33+
34+
# predict on test data
35+
pred_test = predict(mach; rows = test)
36+
37+
# predict on some new dataset
38+
pred = predict(mach, X)
39+
```
40+
41+

docs/src/usage/quickstart.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
```@meta
2+
CurrentModule = Maxnet
3+
```
4+
5+
## Installation
6+
Maxnet.jl is not yet registered - install by running
7+
```julia
8+
]
9+
add https://github.com/tiemvanderdeure/Maxnet.jl
10+
```
11+
12+
## Basic usage
13+
### Fit a model
14+
Use the `maxnet` function to generate a model. `maxnet` takes a `BitVector` as its first arguments, where `true` encodes presences points and `false` background points. As its second argument, it takes any `Tables.jl`-compatible data structure with predictor variables. Categorical variables are treated differently than numeric variables and must be a `CategoricalVector`. Keyword arguments are used to tweak model settings.
15+
16+
`predict` takes a model generated by `maxnet` and any `Tables.jl`-compatible data structure.
17+
18+
Maxnet.jl comes with a sample dataset of presences and background points for the sloth species _Bradypus variegatus_ (see [Philips et al., 2006](https://doi.org/10.1016/j.ecolmodel.2005.03.026) for details).
19+
20+
The following code fits a maxnet model for _Bradypus variegatus_ with default settings and generates the predicted suitability at each point.
21+
22+
```julia
23+
using Maxnet
24+
p_a, env = Maxnet.bradypus()
25+
bradypus_model = maxnet(p_a, env)
26+
prediction = predict(bradypus_model, env)
27+
```
28+
29+
There are numerous settings that can be tweaked to change the model fit. These are documentated in the documentatoin for the `maxnet`(@ref) and `Maxnet.predict`(@ref) functions.
30+
31+
### Model settings
32+
The two most important settings to change when running Maxnet is the feature classes selected and the regularization factor.
33+
34+
By default, the feature classes selected depends on the number of presence points, see [Maxnet.default_features](@ref). To set them manually, specify the `features` keyword using either a `Vector` of `AbstractFeatureClass`, or a `string`, where `l` represents `LinearFeature` and `CategoricalFeature`, `q` represents `QuadraticFeature`, `p` represents `ProductFeature`, `t` represents `ThresholdFeature` and `h` represents `HingeFeature`.
35+
36+
For example:
37+
```julia
38+
model1 = maxnet(p_a, env; features = [LinearFeature(), CategoricalFeature(), QuadraticFeature()])
39+
model2 = maxnet(p_a, env; features = "lqph")
40+
```
41+
42+
The regularization multiplier controls how much the algorithms penalizes complex models. A higher regularization multiplier will result in a simpler model with fewer features.
43+
44+
```julia
45+
model3 = maxnet(p_a, env; features = "lqph", regularization_multiplier = 10.0)
46+
```
47+
48+
The number of features selected is shown when a model is printed in the REPL and can be accessed using `complexity`. Here `complexity(model2)` gives `48` and `complexity(model3)` gives `13`.

0 commit comments

Comments
 (0)