I run the following example in Common MLJ Workflows · MLJ (alan-turing-institute.github.io)
crabs = load_crabs() |> DataFrames.DataFrame
y, X = unpack(crabs, ==(:sp), !in([:index, :sex]); rng=123)
Tree = @load DecisionTreeClassifier pkg=DecisionTree
mach = machine(tree, X, y)
train, test = partition(eachindex(y), 0.7);
yhat = predict(mach, X[test,:])
But it shows “predict not defined”
Why can’t I call predict function.
Works fine for me in a fresh environment on Julia 1.7.2 and I get
julia> mean(LogLoss(tol=1e-4)(yhat, y[test]))
which means you most l likely have either
a) outdated package versions (probably less likely given
predict has always been defined afaik; or
b) loaded another package which exports
predict and conflicts with MLJ’s
Can you run the code in a fresh REPL session and a temp environment to isolate the issue?
But I try another environment on Julia 1.7.1
It shows wrong: Failed to precompile MLJDecisionTreeInterface.
What’s the problem?
I rewrite the
yhat = predict(mach, X[test,:]) as
yhat = MLJ.predict(mach, X[test,:])