Skip to content

Commit 7b7128f

Browse files
committed
commit forgotten new file
1 parent f7289f2 commit 7b7128f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/src/model_wrappers.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Model wrappers
2+
3+
A model that can have one or more other models as hyper-parameters should overload the trait `is_wrapper`, as in this example:
4+
5+
```julia
6+
MLJModelInterface.target_in_fit(::Type{<:MyWrapper}) = true
7+
```
8+
9+
The constructor for such a model does not need provide default values for the model-valued
10+
hyper-parameters. If only a single model is wrapped, then the hyper-parameter should have
11+
the name `:model` and this should be an optional positional argument, as well as a keyword
12+
argument.
13+
14+
For example, `EnsembleModel` is a model wrapper, and we can construct an instance like this:
15+
16+
```julia
17+
using MLJ
18+
atom = ConstantClassfier()
19+
EnsembleModel(tree, n=100)
20+
```
21+
22+
but also like this:
23+
24+
```julia
25+
EnsembleModel(model=tree, n=100)
26+
```
27+
28+
This is the only case in MLJ where positional arguments in a model constructor are
29+
allowed.

0 commit comments

Comments
 (0)