-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |