From da6aab8c30d8b679022298c7c0db9ff7f41a1f69 Mon Sep 17 00:00:00 2001 From: "Anthony Blaom, PhD" Date: Sat, 20 Jul 2024 08:41:11 +1200 Subject: [PATCH 1/2] Fix codecov badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f343b16..c0a6bbc 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ machine learning models into | Linux | Coverage | | :-----------: | :------: | -| [![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) | +| [![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) [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliaai.github.io/MLJModelInterface.jl/dev/) From 5aa10551dffbcacfe7c05392e624f322599ab0ee Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Fri, 2 Aug 2024 13:47:16 +1200 Subject: [PATCH 2/2] add docs about constructor trait --- docs/src/model_wrappers.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/src/model_wrappers.md b/docs/src/model_wrappers.md index 4767e0d..4431368 100644 --- a/docs/src/model_wrappers.md +++ b/docs/src/model_wrappers.md @@ -27,3 +27,21 @@ EnsembleModel(model=tree, n=100) This is the only case in MLJ where positional arguments in a model constructor are allowed. + +## Handling generic constructors + +Model wrappers frequently have a public facing constructor with a name different from that +of the model type constructed. For example, `TunedModel(model, ...)` is a constructor that +will construct either an instance of `DeterministicTunedModel` or +`ProbabilisticTunedModel`, depending on the type of `model`. In this case it is necessary +to overload the `constructor` trait, which in that case looks like this: + +```julia +MLJModelInterface.constructor(::Type{<:Union{ + DeterministicTunedModel, + ProbabilisticTunedModel, + }}) = TunedModel +``` + +This allows the MLJ Model Registry to correctly associate model metadata to the +constructor, rather than the (private) types.