Skip to content

MLJ implementations of KernelPerceptronClassifier, PegasosClassifier, PerceptronClassifier broken #79

@ablaom

Description

@ablaom

Context: JuliaAI/MLJ.jl#1182 (comment)

using MLJ
using MLJTestIntegration

A = @load KernelPerceptronClassifier
X, y = MLJTestIntegration.datasets(A)[1];

mach = machine(A(), X, y)
MLJ.fit!(mach, rows=1:4);
MLJ.predict(mach, X)
# ERROR: xtrain, ytrain or α have a length not compatible with the number of classes in this model.
# Stacktrace:
#  [1] error(s::String)
#    @ Base ./error.jl:35
#  [2] predict(x::Matrix{…}, xtrain::Vector{…}, ytrain::Vector{…}, α::Vector{…}, classes::Vector{…}; K::typeof(radial_kernel))
#    @ BetaML.Perceptron ~/.julia/packages/BetaML/GVo1h/src/Perceptron/Perceptron_kernel.jl:268
#  [3] predict
#    @ ~/.julia/packages/BetaML/GVo1h/src/Perceptron/Perceptron_kernel.jl:259 [inlined]
#  [4] predict(model::BetaML.Bmlj.KernelPerceptronClassifier, fitresult::Tuple{…}, Xnew::@NamedTuple{…})
#    @ BetaML.Bmlj ~/.julia/packages/BetaML/GVo1h/src/Bmlj/Perceptron_mlj.jl:285
#  [5] predict(mach::Machine{…}, Xraw::@NamedTuple{…})
#    @ MLJBase ~/.julia/packages/MLJBase/F8Zzu/src/operations.jl:135
#  [6] top-level scope
#    @ REPL[55]:1
# Some type information was truncated. Use `show(err)` to see complete types.

This looks like only levels explicitly seen in training (and not the complete categorical pool) are being to recorded in the train. I see that there was some unwrapping added in the last release, which I suppose is the cause.

If I recall correctly, the recent patch was to anticipate changes to CategoricalArrays.jl (which MLJ has not addressed). Did the baby get thrown out with the bathwater?

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