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

MLJ Interface is not working anymore #70

Closed
rubsc opened this issue Feb 22, 2024 · 6 comments
Closed

MLJ Interface is not working anymore #70

rubsc opened this issue Feb 22, 2024 · 6 comments

Comments

@rubsc
Copy link

rubsc commented Feb 22, 2024

The code

modelType = @load RandomForestClassifier pkg = "BetaML" verbosity=1
mod = modelType(
n_trees = 2,
max_depth = 10
)

is not working in the latest version of BetaML.

@sylvaticus
Copy link
Owner

going to check, thanks to report....

@sylvaticus
Copy link
Owner

Hello, I can't reproduce... this script, where I used your code, works as expected...

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


# Iris dataset
X, y        = @load_iris

# Your code...
modelType = @load RandomForestClassifier pkg = "BetaML" verbosity=1
mod = modelType(
n_trees = 2,
max_depth = 10
)

mach        = machine(mod, X, y)
fit!(mach)
cat_est    = predict(mach, X)
ŷ =   MLJ.mode.(cat_est)
accuracy = sum(y .== ŷ) / length(y) # 0.95

Be sure you have the latest versions of both MLJ and BetaML (respectively v0.20.2 and v0.11.3)

@sylvaticus
Copy link
Owner

Hello, do you still have the issue after updating to latest versions?

@JoshuaBillson
Copy link

I found this issue because I was having a similar problem. Attempting to load the RandomForestClassifier model directly was failing to resolve, but doing so with @load worked. On further analysis, it appears that RandomForestClassifier is in the sub-module Bmlj, which needs to be explicitly included. For example:

# This Works
model = (MLJ.@load RandomForestClassifier pkg = "BetaML")()

# Also Works
model = BetaML.Bmlj.RandomForestClassifier()

# Doesn't Work
model = BetaML.RandomForestClassifier()

Moreover, the links to the MLJ models appear to be broken in the README.

I'm assuming this is a recent change? It would be nice to be able to access the MLJ models directly from the BetaML module. Alternatively, the documentation should be clearer to avoid confusion.

sylvaticus added a commit that referenced this issue Mar 22, 2024
@sylvaticus
Copy link
Owner

Hi, model = BetaML.RandomForestClassifier() is NOT supposed to work.
You can access RandomForestClassifier and RandomForestRegressor trought the MLJ @load method, or the RandomForestEstimator trought the BetaML interface (the first two are just wrappers to the third one).
While names are different in this case, sometimes the names of the models are the same, this is why BetaML does NOT export the MLJ-interface models.
If you want the MLJ interface models without using @load, you can do:

using BetaML # or import
m = BetaML.Bmlj.RandomForestClassifier()

Thanks for the report on the links and let me know if I can close this issue...

@sylvaticus
Copy link
Owner

..closing... feel free to reopen if needed...

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

3 participants