I’m trying to implement the following or similar architecture, and would really like to hear some advice on how to do it correctly/better/…
Basically, there is going to be many user-defined models, which I think are reasonable to organize like this:
# file model_A.jl
struct ModelParameters
A::Float64
end
eval(m::ModelParameters, x) = ...
loglike(m::ModelParameters, x, y) = ...
# file model_B.jl
struct ModelParameters
B::Float64
end
eval(m::ModelParameters, x) = ...
loglike(m::ModelParameters, x, y) = ...
Then there will be a common file, that handles data loading and e.g. fitting:
function load_model(path)
global model_path = path
include(path)
end
function load_data()
global data = ...
end
function fit_model()
...
loglike(ModelParameters(...), data.x, data.y)
...
end
load_model("model_A.jl")
fit_model()
so far so good. But what to do when I need several models together with their parameter classes and all methods loaded at the same time e.g. for comparison?
What do you thing of this approach in general? Anything obviously wrong, or something better exists?