Skip to content

Problems with predict for MLJ implementations of PegasosClassifier and PerceptronClassifier #80

Description

@ablaom

These models are not working in 0.12.4.

using MLJ
using MLJTestIntegration

A = @load PegasosClassifier pkg = BetaML

X, y = MLJTestIntegration.datasets(A)[2];

mach = machine(A(), X, y)
MLJ.fit!(mach, rows=1:4);
MLJ.predict(mach, X)

# ERROR: BoundsError: attempt to access 1-element Vector{Vector{Float64}} at index [2]
# Stacktrace:
#  [1] throw_boundserror(A::Vector{Vector{Float64}}, I::Tuple{Int64})
#    @ Base ./essentials.jl:14
#  [2] getindex
#    @ ./essentials.jl:916 [inlined]
#  [3] predict(x::Matrix{Float64}, θ::Vector{Vector{Float64}}, θ₀::Vector{Float64}, classes::Vector{String})
#    @ BetaML.Perceptron ~/.julia/packages/BetaML/esA5J/src/Perceptron/Perceptron_classic.jl:266
#  [4] predict(model::BetaML.Bmlj.PegasosClassifier, fitresult::Tuple{…}, Xnew::@NamedTuple{…}
# )
#    @ BetaML.Bmlj ~/.julia/packages/BetaML/esA5J/src/Bmlj/Perceptron_mlj.jl:262
#  [5] predict(mach::Machine{…}, Xraw::@NamedTuple{…})
#    @ MLJBase ~/.julia/packages/MLJBase/F8Zzu/src/operations.jl:135
#  [6] top-level scope
#    @ REPL[48]:1
# Some type information was truncated. Use `show(err)` to see complete types.


B = @load PerceptronClassifier pkg = BetaML

X, y = MLJTestIntegration.datasets(B)[2];

mach = machine(A(), X, y)
MLJ.fit!(mach, rows=1:4);
MLJ.predict(mach, X)

# ERROR: BoundsError: attempt to access 1-element Vector{Vector{Float64}} at index [2]
# Stacktrace:
#  [1] throw_boundserror(A::Vector{Vector{Float64}}, I::Tuple{Int64})
#    @ Base ./essentials.jl:14
#  [2] getindex
#    @ ./essentials.jl:916 [inlined]
#  [3] predict(x::Matrix{Float64}, θ::Vector{Vector{Float64}}, θ₀::Vector{Float64}, classes::Vector{String})
#    @ BetaML.Perceptron ~/.julia/packages/BetaML/esA5J/src/Perceptron/Perceptron_classic.jl:266
#  [4] predict(model::BetaML.Bmlj.PegasosClassifier, fitresult::Tuple{…}, Xnew::@NamedTuple{…}
# )
#    @ BetaML.Bmlj ~/.julia/packages/BetaML/esA5J/src/Bmlj/Perceptron_mlj.jl:262
#  [5] predict(mach::Machine{…}, Xraw::@NamedTuple{…})
#    @ MLJBase ~/.julia/packages/MLJBase/F8Zzu/src/operations.jl:135
#  [6] top-level scope
#    @ REPL[53]:1
# Some type information was truncated. Use `show(err)` to see complete types.

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