Giter Club home page Giter Club logo

Comments (3)

sylvaticus avatar sylvaticus commented on May 25, 2024 1

I have implemented the mixtures option in the MLJ interface as either :diag_gaussian, :full_gaussian or :spherical_gaussian.
For the rest I would prefer keep the model current approach for now.

from betaml.jl.

sylvaticus avatar sylvaticus commented on May 25, 2024

Hello, I have implemented deepcopy of the model initial mixtures in commit 5ea564f340c9ec9246d51eac8098e44058820ac9 so that the original model mixtures (and initial mixture prior probabilities) aren't modified in fit.

Be aware however that the check you used still wouldn't work. In Julia indeed custom types (as BetaML.Mixture) need to implement == explicitly and I didn't do it for the mixtures I defined:

struct MyStruct
    x::Int64
end
obj1 = MyStruct(1)
obj2 = MyStruct(2)
obj3 = deepcopy(obj1)

obj1 == obj2 # false
obj3 == obj2 # false

# Let's implement `==` for MyStruct: 
import Base.==
==(a::MyStruct,b::MyStruct) = a.x == a.x

obj1 == obj2 # now it's true
obj3 == obj2 # now it's true

from betaml.jl.

ablaom avatar ablaom commented on May 25, 2024

Yes, you are right, I had overlooked this (despite having overloaded == for Model precisely for this reason 😄 ). This issue should be made explicit in the model API docs.

At first glance, this is likely not an issue in this case. As far as I can tell, the only place == for models is used is to check conditions for a "warm restart" when fit!ing a machine (https://alan-turing-institute.github.io/MLJ.jl/dev/machines/). If your model does not implement MMI.update, this is a moot point.

However, I think passing "empty objects" as way of specifying what is required is not ideal. What about doing something like mixtures=:diagonal_guassian. That way the user needn't refer to (and first find) the custom type DiagonalGuassian (currently buried as BetaML.Clustering.DiagonalGuassian). If possible, it's nice if users do not need to refer to model-specific types.

If the point is to maintain an interface point for "partially trained" mixtures, then the appropriate way to integrate with MLJ is to pass the mixtures (and posterior class probabilities) calculated by fit to cache and implement MMI.update, which continues training where it left off if the only change to the model is the iteration parameter (tested with MMI.is_same_except method). See https://alan-turing-institute.github.io/MLJ.jl/dev/adding_models_for_general_use/#Iterative-models-and-the-update!-method-1 . User access to trained mixtures is via fitted_params. (Another advantage of doing this is that MLJ will very soon have a model wrapper for controlling any iterative model of this kind, provided it is supervised - one reason for my suggesting having an implementation of GMM that is supervised.)

I should say that implementing update for the EM-based models is bells and whistles that could be added later. But good to keep in mind.

from betaml.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.