JuliaAI / MLJ.jl

A Julia machine learning framework
https://juliaai.github.io/MLJ.jl/
Other
1.79k stars 158 forks source link

Add AutoEncoderMLJ model (part of BetaML) #1074

Closed sylvaticus closed 9 months ago

sylvaticus commented 10 months ago

Hello, I have added to BetaML a model to use a AutoEncoder in a very simple way from the end user prospective, without the need to understand the underlying neural network. I have also created a MLJ wrapper, AutoEncoderMLJ. As this is my first transformer for MLJ, could you please check that the wrapper is fine and eventually add it to the MLJ registry ?

Thank you :-)

ablaom commented 10 months ago

Thanks @sylvaticus for adding the wrapper. It's mostly good.

Main thing is that

mutable struct AutoEncoderMLJ <: MLJModelInterface.Deterministic

should be

mutable struct AutoEncoderMLJ <: MLJModelInterface.Unsupervised

Having "MLJ" in the name is unfortunate. Perhaps you put the interface in a submodule to prevent name conflict with AutoEncoder? If you do that, you need to need to amend the load path at https://github.com/sylvaticus/BetaML.jl/blob/38074a9207ba36bd3427bc31eef42f7b990d1ac8/src/Utils/Utils_MLJ.jl#L159

The doc string is great but not strictly compliant. There are examples for transformers (Unsupervised models) at the end of this page.

There's no need to implement predict for Unsupervised models.

Feel free to add the following interface test, but that's up to you:

import BetaML
using MLJTestInterface

@testset "generic mlj interface test" begin
    fails, summary = MLJTestInterface.test(
        [BetaML.Utils.AutoEncoderMLJ,],
        MLJTestInterface.make_regression()[1];
        mod=@__MODULE__,
        verbosity=0, # bump to debug
        throw=false, # set to true to debug
    )
    @test isempty(failures)
end
ablaom commented 9 months ago

FYI I have just updated the MLJ Model Registry which has automatically added this model - my mistake. I don't think that's a big deal, but do let me know as soon as you have fixed Deterministic -> Unsupervised so I can update the registry again.

sylvaticus commented 9 months ago

yes, I am working on it... I didn't yet asked your opinion as I didn't yet tested it (and haven't touched the doc).

Thank you for the suggestion about submodules, I will be able to use the same name for native and MLJ interface models, although this is breaking....

Antonello

On Wed, 10 Jan 2024, 20:36 Anthony Blaom, PhD, @.***> wrote:

FYI I have just updated the MLJ Model Registry which has automatically added this model - my mistake. I don't think that's a big deal, but do let me know as soon as you have fixed Deterministic -> Unsupervised so I can update the registry again.

— Reply to this email directly, view it on GitHub https://github.com/alan-turing-institute/MLJ.jl/issues/1074#issuecomment-1885582533, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAP3DZ65ZKBCBZCE7J6NWFDYN3UUFAVCNFSM6AAAAABBG2L5C6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGU4DENJTGM . You are receiving this because you were mentioned.Message ID: @.***>

sylvaticus commented 9 months ago

I have fixed the Deterministic -> Unsupervised issue and changed its name to AutoEncoder by setting the MLJ in its own submodule BetaML.Bmlj.

MLJTestInterface.test passes, but I am still unsure about MLJModelInterface.metadata_pkg.. there (at the end of /src/BetaML.jl file) I use Bmlj.AutoEncoder, is it fine like that ?

ablaom commented 9 months ago

MLJTestInterface.test passes, but I am still unsure about MLJModelInterface.metadata_pkg.. there (at the end of /src/BetaML.jl file) I use Bmlj.AutoEncoder, is it fine like that ?

I'm not completely sure I understand the question, but I do see that the package-related metadata is getting defined for Bmlj.AutoEncoder:

julia> package_name(BetaML.Bmlj.AutoEncoder)
"BetaML"

Is that what you were worried about?

sylvaticus commented 9 months ago

Yes, is it fine like that?

ablaom commented 9 months ago

Yes. It looks good to me. The most important thing is that the load path is good and it is:

julia> load_path(BetaML.Bmlj.AutoEncoder)
"BetaML.Bmlj.AutoEncoder"
ablaom commented 9 months ago

Note to self: This issue is addressed on BetaML#master; waiting for next release (currently at 0.10.4).

sylvaticus commented 9 months ago

just done it. Released v0.11.0 with all MLJ interface models isolated in their own submodule. This allowed the MLJ model struct to share the same name with BetaML models and I have taken the occasion to uniform all the model names.. (so, unfortunately, big breaking release)..

ablaom commented 9 months ago

Congratulations on the refactor.

This is issue can be closed after: