Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load issue #752

Closed
azev77 opened this issue Mar 19, 2021 · 1 comment
Closed

Load issue #752

azev77 opened this issue Mar 19, 2021 · 1 comment

Comments

@azev77
Copy link
Contributor

azev77 commented Mar 19, 2021

Previously the following worked to automatically load all models:

for (i, model) in enumerate(models())
    load(model.name, pkg=model.package_name, verbosity=0) 
end

Now I get an error message:

ERROR: The `load` function is no longer supported. Use the `@load` macro instead, as in `@load RandomForestRegressor pkg = DecisionTree`.

Then I try:

for (i, model) in enumerate(models())
    @load model.name pkg = model.package_name
end

ERROR: ArgumentError: There is no model named "model.name" in the registry. 
 Run `models()` to view all registered models.
@ablaom
Copy link
Member

ablaom commented Mar 22, 2021

What you want to do is use interpolation, as in

name = "PCA"
@load $name

But @load does not support this yet (JuliaAI/MLJModels.jl#368). However there is a workaround:

name = "PCA"
@eval @load $name

So the following works for me:

using Pkg
Pkg.activate(temp=true)
Pkg.add("MLJ")

using MLJ
model_types = []
for model in models()
    T = @eval @load $(model.name) pkg=$(model.package_name) add=true
    push!(model_types, T)
end
model_instances = map(T -> T(), model_types)

@ablaom ablaom closed this as completed Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants