Skip to content

[MLJ interface] NeuralNetworkClassifier falsely claims to support Count target #75

@ablaom

Description

@ablaom
using BetaML
using MLJBase

X = (x1 = rand(5), x2 = rand(5))
y = [1, 2, 3, 2, 1]

scitype(y)
# AbstractVector{Count}

M = BetaML.Bmlj.NeuralNetworkClassifier

@assert scitype(y) <: target_scitype(M)

verbosity = 0
MLJBase.fit(M(), verbosity, X, y)
# ERROR: MethodError: Cannot `convert` an object of type
#   Nothing to an object of type
#   Vector
# The function `convert` exists, but no method is defined for this combination of argument types.

# Closest candidates are:
#   convert(::Type{Vector}, ::StatsBase.UnitWeights{T}) where T
#    @ StatsBase ~/.julia/packages/StatsBase/xgoZ5/src/weights.jl:317
#   convert(::Type{Vector}, ::StatsBase.AbstractWeights)
#    @ StatsBase ~/.julia/packages/StatsBase/xgoZ5/src/weights.jl:35
#   convert(::Type{T}, ::T) where T
#    @ Base Base.jl:126
#   ...

# Stacktrace:
#  [1] setproperty!(x::BetaML.Utils.OneHotEncoder_lp, f::Symbol, v::Nothing)
#    @ Base ./Base.jl:52
#  [2] BetaML.Utils.OneHotEncoder(; kwargs::@Kwargs{…})
#    @ BetaML.Utils ~/.julia/packages/BetaML/NDCDt/src/Utils/Processing.jl:219
#  [3] fit(m::BetaML.Bmlj.NeuralNetworkClassifier, verbosity::Int64, X::@NamedTuple{…}, y::Vector{…})
#    @ BetaML.Bmlj ~/.julia/packages/BetaML/NDCDt/src/Bmlj/Nn_mlj.jl:342
#  [4] top-level scope
#    @ REPL[40]:1
# Some type information was truncated. Use `show(err)` to see complete types.
Status `/private/var/folders/4n/gvbmlhdc8xj973001s6vdyw00000gq/T/jl_smBPYW/Project.toml`
  [024491cd] BetaML v0.12.1
  [a7f614a8] MLJBase v1.7.0
julia> versioninfo()
Julia Version 1.11.1
Commit 8f5b7ca12ad (2024-10-16 10:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (x86_64-apple-darwin22.4.0)
  CPU: 12 × Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, skylake)
Threads: 12 default, 0 interactive, 6 GC (on 12 virtual cores)
Environment:
  JULIA_LTS_PATH = /Applications/Julia-1.10.app/Contents/Resources/julia/bin/julia
  JULIA_PATH = /Applications/Julia-1.11.app/Contents/Resources/julia/bin/julia
  JULIA_EGLOT_PATH = /Applications/Julia-1.7.app/Contents/Resources/julia/bin/julia
  JULIA_NUM_THREADS = 12
  JULIA_NIGHTLY_PATH = /Applications/Julia-1.11.app/Contents/Resources/julia/bin/julia

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions