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

predict throws an error for MultinomialClassifier on crabs dataset #129

Closed
ablaom opened this issue Sep 16, 2022 · 0 comments
Closed

predict throws an error for MultinomialClassifier on crabs dataset #129

ablaom opened this issue Sep 16, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@ablaom
Copy link
Member

ablaom commented Sep 16, 2022

using MLJ
using MLJLinearModels
data = MLJ.load_crabs();
y_, X = unpack(data, ==(:sp), col->col in [:FL, :RW]);
y = coerce(y_, MLJ.OrderedFactor);
model = MultinomialClassifier()
mach = machine(model, X, y) |> fit!

julia> predict(mach, X)
ERROR: DimensionMismatch("Probability array is incompatible with the number of classes, 2, which should be equal to `4`, the last dimension of the probability array. Perhaps you meant to set `augment=true`? ")
Stacktrace:
  [1] _UnivariateFinite(support::CategoricalArrays.CategoricalVector{String, UInt32, String, CategoricalArrays.CategoricalValue{String, UInt32}, Union{}}, probs::Matrix{Float64}, N::Int64; augment::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ CategoricalDistributions ~/.julia/packages/CategoricalDistributions/eSHdo/src/types.jl:401                                                                                
  [2] #_UnivariateFinite#17
    @ ~/.julia/packages/CategoricalDistributions/eSHdo/src/types.jl:483 [inlined]
  [3] _UnivariateFinite(::Val{true}, support::CategoricalArrays.CategoricalVector{String, UInt32, String, CategoricalArrays.CategoricalValue{String, UInt32}, Union{}}, probs::Matrix{Float64})                                                                                  
    @ CategoricalDistributions ~/.julia/packages/CategoricalDistributions/eSHdo/src/types.jl:483                                                                                
  [4] UnivariateFinite(support::CategoricalArrays.CategoricalVector{String, UInt32, String, CategoricalArrays.CategoricalValue{String, UInt32}, Union{}}, probs::Matrix{Float64}; kwargs
::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})                           
    @ CategoricalDistributions ~/.julia/packages/CategoricalDistributions/eSHdo/src/types.jl:383                                                                                
  [5] UnivariateFinite
    @ ~/.julia/packages/CategoricalDistributions/eSHdo/src/types.jl:372 [inlined]
  [6] #UnivariateFinite#25
    @ ~/MLJ/MLJBase/src/interface/data_utils.jl:137 [inlined]
  [7] UnivariateFinite
    @ ~/MLJ/MLJBase/src/interface/data_utils.jl:137 [inlined]
  [8] #UnivariateFinite#14
    @ ~/MLJ/MLJModelInterface/src/data_utils.jl:594 [inlined]
  [9] UnivariateFinite(support::CategoricalArrays.CategoricalVector{String, UInt32, String, CategoricalArrays.CategoricalValue{String, UInt32}, Union{}}, probs::Matrix{Float64})
    @ MLJModelInterface ~/MLJ/MLJModelInterface/src/data_utils.jl:594
 [10] predict(m::MultinomialClassifier, ::Tuple{Vector{Float64}, Tuple{Symbol, Symbol}, CategoricalArrays.CategoricalVector{String, UInt32, String, CategoricalArrays.CategoricalValue{String, UInt32}, Union{}}, Int64}, Xnew::NamedTuple{(:FL, :RW), Tuple{Vector{Float64}, Vector{Float64}}})                                      
    @ MLJLinearModels ~/.julia/packages/MLJLinearModels/YvwMg/src/mlj/interface.jl:92
 [11] predict(mach::Machine{MultinomialClassifier, true}, Xraw::NamedTuple{(:FL, :RW), Tuple{Vector{Float64}, Vector{Float64}}})                                      
    @ MLJBase ~/MLJ/MLJBase/src/operations.jl:133
 [12] top-level scope
    @ REPL[32]:1
 [13] top-level scope
    @ ~/.julia/packages/CUDA/DfvRa/src/initialization.jl:52
@ablaom ablaom added the bug Something isn't working label Sep 16, 2022
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

1 participant