Installation
Maxnet.jl is not yet registered - install by running
]
add https://github.com/tiemvanderdeure/Maxnet.jl
Basic usage
Fit a model
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.
predict
takes a model generated by maxnet
and any Tables.jl
-compatible data structure.
Maxnet.jl comes with a sample dataset of presences and background points for the sloth species Bradypus variegatus (see Philips et al., 2006 for details).
The following code fits a maxnet model for Bradypus variegatus with default settings and generates the predicted suitability at each point.
using Maxnet
p_a, env = Maxnet.bradypus()
bradypus_model = maxnet(p_a, env)
prediction = predict(bradypus_model, env)
There are numerous settings that can be tweaked to change the model fit. These are documentated in the documentation for the maxnet
and predict
functions.
Model settings
The two most important settings to change when running Maxnet is the feature classes selected and the regularization factor.
By default, the feature classes selected depends on the number of presence points, see Maxnet.default_features. 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
.
For example:
model1 = maxnet(p_a, env; features = [LinearFeature(), CategoricalFeature(), QuadraticFeature()])
model2 = maxnet(p_a, env; features = "lqph")
The regularization multiplier controls how much the algorithms penalizes complex models. A higher regularization multiplier will result in a simpler model with fewer features.
model3 = maxnet(p_a, env; features = "lqph", regularization_multiplier = 10.0)
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
.