JuliaAI / MLJModelInterface.jl

Lightweight package to interface with MLJ
MIT License
37 stars 8 forks source link

Add `report` method for merging fit reports with operational reports #160

Closed ablaom closed 2 years ago

ablaom commented 2 years ago

In support of https://github.com/JuliaAI/MLJBase.jl/issues/831.

A non-breaking enhancement.

In this PR we:

The docstring for the new method is copied below.

```julia MLJModelInterface.report(model, report_given_method) ``` Merge the reports in the dictionary `report_given_method` into a single property-accessible object. It is supposed that the keys of the dictionary are `:fit` and the symbolic names of MLJModelInterface.jl operations, such as `:predict` or `:transform`. Each value will be the `report` component returned by a training method (`fit` or `update`) dispatched on the `model` type, in the case of `:fit`, or the report component returned by an operation that supports reporting. ### New model implementations Overloading this method is optional, unless the model generates reports that are neither named tuples nor `nothing`. Assuming each dictionary value is a named tuple or `nothing`, the fallback returns the usual named tuple merge of the dictionary values, ignoring any `nothing` values, and assuming there are no conflicts between the keys of the dictionary values (the individual reports). If there is a key conflict, all operation reports are first wrapped in a named tuple of length one, as in `(predict=predict_report,)`. If any dictionary `value` is neither a named tuple nor `nothing`, it is first wrapped as `(report=value, )` before merging.
codecov-commenter commented 2 years ago

Codecov Report

Merging #160 (ed0fd8c) into dev (7cd0ecf) will decrease coverage by 0.05%. The diff coverage is 84.21%.

@@            Coverage Diff             @@
##              dev     #160      +/-   ##
==========================================
- Coverage   88.75%   88.70%   -0.06%     
==========================================
  Files           8        8              
  Lines         329      354      +25     
==========================================
+ Hits          292      314      +22     
- Misses         37       40       +3     
Impacted Files Coverage Δ
src/metadata_utils.jl 98.36% <50.00%> (-1.64%) :arrow_down:
src/model_api.jl 77.77% <88.23%> (+17.77%) :arrow_up:
src/equality.jl 100.00% <0.00%> (ø)
src/model_def.jl 100.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

ablaom commented 2 years ago

@OkonSamuel