ilkerarslan / NovaML.jl

https://ilkerarslan.github.io/NovaML.jl/
MIT License
23 stars 3 forks source link

Alternative syntax for fitting a model #17

Closed CameronBieganek closed 1 week ago

CameronBieganek commented 1 week ago

I don't want to do too much bikeshedding, but it seems to me that model(X, y) and model(X) do very different things and they deserve a separate syntax. I like model(X) for prediction, since models are just function approximators. But for fitting I would recommend this syntax:

fit!(model, X, y)

This syntax makes it more clear that model is being mutated during the fitting process, since we are using the standard Julia convention that mutation is indicated by function names with an exclamation point. With the model(X, y) syntax it's not very obvious that fitting and mutation are occurring.

ilkerarslan commented 1 week ago

Thanks for the suggestion. I have thought about it and I decided using one structure (functor) for keeping parameters, training and predicting. Other frameworks already use fit!( ) mutating function. It has its own pros of course but I just like calling one structure for everything. In fact I like multiple dispatch and functors in Julia and using them wherever I can :)