File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -27,3 +27,21 @@ EnsembleModel(model=tree, n=100)
2727
2828This is the only case in MLJ where positional arguments in a model constructor are
2929allowed.
30+
31+ ## Handling generic constructors
32+
33+ Model wrappers frequently have a public facing constructor with a name different from that
34+ of the model type constructed. For example, ` TunedModel(model, ...) ` is a constructor that
35+ will construct either an instance of ` DeterministicTunedModel ` or
36+ ` ProbabilisticTunedModel ` , depending on the type of ` model ` . In this case it is necessary
37+ to overload the ` constructor ` trait, which in that case looks like this:
38+
39+ ``` julia
40+ MLJModelInterface. constructor (:: Type {<: Union {
41+ DeterministicTunedModel,
42+ ProbabilisticTunedModel,
43+ }}) = TunedModel
44+ ```
45+
46+ This allows the MLJ Model Registry to correctly associate model metadata to the
47+ constructor, rather than the (private) types.
You can’t perform that action at this time.
0 commit comments