Skip to content

Commit

Permalink
commit forgotten new file
Browse files Browse the repository at this point in the history
  • Loading branch information
ablaom committed Jul 3, 2024
1 parent f7289f2 commit 7b7128f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/src/model_wrappers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Model wrappers

A model that can have one or more other models as hyper-parameters should overload the trait `is_wrapper`, as in this example:

```julia
MLJModelInterface.target_in_fit(::Type{<:MyWrapper}) = true
```

The constructor for such a model does not need provide default values for the model-valued
hyper-parameters. If only a single model is wrapped, then the hyper-parameter should have
the name `:model` and this should be an optional positional argument, as well as a keyword
argument.

For example, `EnsembleModel` is a model wrapper, and we can construct an instance like this:

```julia
using MLJ
atom = ConstantClassfier()
EnsembleModel(tree, n=100)
```

but also like this:

```julia
EnsembleModel(model=tree, n=100)
```

This is the only case in MLJ where positional arguments in a model constructor are
allowed.

0 comments on commit 7b7128f

Please sign in to comment.