I am trying to run the most basic example from MLJ getting started tutorial and I am getting an error when trying to unpack the iris dataset
y,x = unpack(iris, ==(:target); rng=123)
I get
ERROR: BoundsError: attempt to access Tuple{CategoricalArrays.CategoricalVector{String, UInt32, String, CategoricalArrays.CategoricalValue{String, UInt32}, Union{}}} at index
The error somehow relates to that there are two return values, if I leave only one (x = unpack…) it works
What’s going on ? I have just copied code from a tutorial how come it is failing to run ?
What am I meesing ?
I am using Julia 1.9.1 On windows 10, Here is the complete program:
julia> using MLJ, DataFrames
julia> iris = DataFrame(load_iris());
julia> y, x = unpack(iris, ==(:target));
julia> typeof(x)
DataFrame
julia> typeof(y)
CategoricalVector{String, UInt32, String, CategoricalValue{String, UInt32}, Union{}}
(I’m not showing the actual values of x and y here as they are large but they are as expected.
With these kinds of questions (“why is this code I copied not working as expected”) I recommend two things:
Actually link to where you found the code; and
Tell people the versions of all of the packages you are using (i.e. the output of ]st in the REPL) - 9 times out of 10 you are just using an outdated version of a package (or reading outdated docs while using a newer version of the package)
In general I would recommend working in project environments - the problem you encountered most often stems from a crowded default environment, which can be easily avoided.