Skip to content

Commit 7fb5487

Browse files
authored
Merge pull request #210 from JuliaAI/dev
Update docs
2 parents fae094c + 03ccc2d commit 7fb5487

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ machine learning models into
77

88
| Linux | Coverage |
99
| :-----------: | :------: |
10-
| [![Build Status](https://github.com/JuliaAI/MLJModelInterface.jl/workflows/CI/badge.svg)](https://github.com/JuliaAI/MLJModelInterface.jl/actions) | [![codecov.io](http://codecov.io/github/JuliaAI/MLJModelInterface.jl/coverage.svg?branch=master)](http://codecov.io/github/JuliaAI/MLJModelInterface.jl?branch=master) |
10+
| [![Build Status](https://github.com/JuliaAI/MLJModelInterface.jl/workflows/CI/badge.svg)](https://github.com/JuliaAI/MLJModelInterface.jl/actions) | [![codecov](https://codecov.io/github/JuliaAI/MLJModelInterface.jl/graph/badge.svg?token=rkvwHku1dW)](https://codecov.io/github/JuliaAI/MLJModelInterface.jl)
1111

1212
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliaai.github.io/MLJModelInterface.jl/dev/)
1313

docs/src/model_wrappers.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,21 @@ EnsembleModel(model=tree, n=100)
2727

2828
This is the only case in MLJ where positional arguments in a model constructor are
2929
allowed.
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.

0 commit comments

Comments
 (0)