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

[BUG]: Argument Error when running predict through MLJ interface. #341

Closed
KevinG1002 opened this issue Aug 27, 2024 · 2 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@KevinG1002
Copy link

What happened?

Hello!

I was trying to run the following command MLJ.predict(mach, (data = periodic_X, idx=params.best_idx)) taken from this library's basic tutorial but ran into the following error:

ERROR: LoadError: ArgumentError: `matrix` method only supports AbstractMatrix or containers implementing the Tables interface.
Stacktrace:
  [1] _matrix(::MLJModelInterface.FullInterface, ::Val{:other}, X::NamedTuple{(:data, :idx), Tuple{Matrix{Float64}, Int64}}; kw::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:transpose,), Tuple{Bool}}})
    @ MLJModelInterface ~/.julia/packages/MLJModelInterface/y9x5A/src/data_utils.jl:49
  [2] matrix(m::MLJModelInterface.FullInterface, v::Val{:other}, X::NamedTuple{(:data, :idx), Tuple{Matrix{Float64}, Int64}}; kw::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:transpose,), Tuple{Bool}}})
    @ MLJModelInterface ~/.julia/packages/MLJModelInterface/y9x5A/src/data_utils.jl:45
  [3] matrix(X::NamedTuple{(:data, :idx), Tuple{Matrix{Float64}, Int64}}; kw::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:transpose,), Tuple{Bool}}})
    @ MLJModelInterface ~/.julia/packages/MLJModelInterface/y9x5A/src/data_utils.jl:38
  [4] get_matrix_and_info(X::NamedTuple{(:data, :idx), Tuple{Matrix{Float64}, Int64}}, #unused#::Type{DynamicQuantities.SymbolicDimensions{DynamicQuantities.FixedRational{Int32, 25200}}})
    @ SymbolicRegression.MLJInterfaceModule ~/.julia/packages/SymbolicRegression/5HYEt/src/MLJInterface.jl:218
  [5] predict(m::SRRegressor{DynamicQuantities.SymbolicDimensions{DynamicQuantities.FixedRational{Int32, 25200}}, DataType, false}, fitresult::NamedTuple{(:state, :num_targets, :options, :variable_names, :y_variable_names, :y_is_table, :X_units, :y_units, :types), Tuple{Tuple{Vector{Vector{SymbolicRegression.PopulationModule.Population{Float64, Float64}}}, SymbolicRegression.HallOfFameModule.HallOfFame{Float64, Float64}}, Int64, SymbolicRegression.CoreModule.OptionsStructModule.Options{Int64, DynamicExpressions.OperatorEnumModule.OperatorEnum, false, Optim.Options{Float64, Nothing}, StatsBase.Weights{Float64, Float64, Vector{Float64}}}, Vector{String}, Nothing, Bool, Nothing, Nothing, NamedTuple{(:T, :X_t, :y_t, :w_t, :state, :X_units, :y_units, :X_units_clean, :y_units_clean), NTuple{9, DataType}}}}, Xnew::NamedTuple{(:data, :idx), Tuple{Matrix{Float64}, Int64}})
    @ SymbolicRegression.MLJInterfaceModule ~/.julia/packages/SymbolicRegression/5HYEt/src/MLJInterface.jl:342
  [6] predict(mach::Machine{SRRegressor{DynamicQuantities.SymbolicDimensions{DynamicQuantities.FixedRational{Int32, 25200}}, DataType, false}, SRRegressor{DynamicQuantities.SymbolicDimensions{DynamicQuantities.FixedRational{Int32, 25200}}, DataType, false}, true}, Xraw::NamedTuple{(:data, :idx), Tuple{Matrix{Float64}, Int64}})
    @ MLJBase ~/.julia/packages/MLJBase/7nGJF/src/operations.jl:135

It is worth noting that periodic_X is of type Matrix{Float64} and mach is my fitted model. Any chance you've seen this before?

Best,

Kevin

Version

0.22.2

Operating System

macOS

Interface

Script (i.e., python my_script.py), Julia REPL

Relevant log output

ERROR: LoadError: ArgumentError: `matrix` method only supports AbstractMatrix or containers implementing the Tables interface.
Stacktrace:
  [1] _matrix(::MLJModelInterface.FullInterface, ::Val{:other}, X::NamedTuple{(:data, :idx), Tuple{Matrix{Float64}, Int64}}; kw::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:transpose,), Tuple{Bool}}})
    @ MLJModelInterface ~/.julia/packages/MLJModelInterface/y9x5A/src/data_utils.jl:49
  [2] matrix(m::MLJModelInterface.FullInterface, v::Val{:other}, X::NamedTuple{(:data, :idx), Tuple{Matrix{Float64}, Int64}}; kw::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:transpose,), Tuple{Bool}}})
    @ MLJModelInterface ~/.julia/packages/MLJModelInterface/y9x5A/src/data_utils.jl:45
  [3] matrix(X::NamedTuple{(:data, :idx), Tuple{Matrix{Float64}, Int64}}; kw::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:transpose,), Tuple{Bool}}})
    @ MLJModelInterface ~/.julia/packages/MLJModelInterface/y9x5A/src/data_utils.jl:38
  [4] get_matrix_and_info(X::NamedTuple{(:data, :idx), Tuple{Matrix{Float64}, Int64}}, #unused#::Type{DynamicQuantities.SymbolicDimensions{DynamicQuantities.FixedRational{Int32, 25200}}})
    @ SymbolicRegression.MLJInterfaceModule ~/.julia/packages/SymbolicRegression/5HYEt/src/MLJInterface.jl:218
  [5] predict(m::SRRegressor{DynamicQuantities.SymbolicDimensions{DynamicQuantities.FixedRational{Int32, 25200}}, DataType, false}, fitresult::NamedTuple{(:state, :num_targets, :options, :variable_names, :y_variable_names, :y_is_table, :X_units, :y_units, :types), Tuple{Tuple{Vector{Vector{SymbolicRegression.PopulationModule.Population{Float64, Float64}}}, SymbolicRegression.HallOfFameModule.HallOfFame{Float64, Float64}}, Int64, SymbolicRegression.CoreModule.OptionsStructModule.Options{Int64, DynamicExpressions.OperatorEnumModule.OperatorEnum, false, Optim.Options{Float64, Nothing}, StatsBase.Weights{Float64, Float64, Vector{Float64}}}, Vector{String}, Nothing, Bool, Nothing, Nothing, NamedTuple{(:T, :X_t, :y_t, :w_t, :state, :X_units, :y_units, :X_units_clean, :y_units_clean), NTuple{9, DataType}}}}, Xnew::NamedTuple{(:data, :idx), Tuple{Matrix{Float64}, Int64}})
    @ SymbolicRegression.MLJInterfaceModule ~/.julia/packages/SymbolicRegression/5HYEt/src/MLJInterface.jl:342
  [6] predict(mach::Machine{SRRegressor{DynamicQuantities.SymbolicDimensions{DynamicQuantities.FixedRational{Int32, 25200}}, DataType, false}, SRRegressor{DynamicQuantities.SymbolicDimensions{DynamicQuantities.FixedRational{Int32, 25200}}, DataType, false}, true}, Xraw::NamedTuple{(:data, :idx), Tuple{Matrix{Float64}, Int64}})
    @ MLJBase ~/.julia/packages/MLJBase/7nGJF/src/operations.jl:135

Extra Info

No response

@KevinG1002 KevinG1002 added the bug Something isn't working label Aug 27, 2024
@MilesCranmer
Copy link
Owner

That feature was not implemented until recently. Could you try the current version, v0.24.5? (You mentioned you are using v0.22.2)

@KevinG1002
Copy link
Author

Hi @MilesCranmer -- confirming that it works :-) Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants