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? #98

Closed
ablaom opened this issue Jan 11, 2024 · 1 comment · Fixed by #100
Closed

Bug? #98

ablaom opened this issue Jan 11, 2024 · 1 comment · Fixed by #100

Comments

@ablaom
Copy link
Contributor

ablaom commented Jan 11, 2024

It seems that the MLJ interface for this package has stopped working, without any change to the code: JuliaAI/MLJLIBSVMInterface.jl#18

The culprit appears to be the linear SVC model. Locally testing this package reveals no problem, but it looks to me that there are no tests for the linear case. A MWE that reproduces the same fail observed in the MLJ interface package is below:

using LIBSVM

n, p = 500, 2
X = rand(p, n)
y = rand([0, 1], n)
solver = LIBSVM.Linearsolver.L2R_L2LOSS_SVC_DUAL 
C = 1.0
bias = -1.0
eps = Inf
verbose = true

LIBSVM.LIBLINEAR.linear_train(
    y,
    X;
    solver_type = Int32(solver),  # this is just `Int32(1)`
    C,
    bias,
    eps,
    verbose,
)

# ERROR: Please check your parameters: Initial-solution specification supported only for solvers L2R_LR, L2R_L2LOSS_SVC, and L2R_L2LOSS_SVR
# Stacktrace:
#  [1] error(s::String)
#    @ Base ./error.jl:35
#  [2] linear_train(labels::Vector{…}, instances::Matrix{…}; weights::Nothing, solver_type::Int32, eps::Float64, C::Float64, p::Float64, init_sol::Ptr{…}, bias::Float64, verbose::Bool)
#    @ LIBLINEAR ~/.julia/packages/LIBLINEAR/77yny/src/LIBLINEAR.jl:227
#  [3] top-level scope
#    @ REPL[26]:1
# Some type information was truncated. Use `show(err)` to see complete types.

All my testing is with julia v1.10.0 and LIBSVM v0.8.0.

Since the last release of LIBSVM.jl, there was an update to the C library, LIBLINEAR. From their website: "Version 2.47 released on July 9, 2023. We fix some minor bugs." Could this be the culprit? Be good if someone else can confirm this or otherwise resolve the issue 😄.

barucden added a commit to barucden/LIBSVM.jl that referenced this issue Jan 28, 2024
We were missing the fields `nu` and `regularize_bias` in the `Parameter`
structure.

Fixes JuliaML#98.
@barucden
Copy link
Member

It is a bug in LIBLINEAR.jl. Structure Parameter was not properly mirroring the corresponding C structure in LIBLINEAR. I pushed a quick fix (see JuliaML/LIBLINEAR.jl#29), but it needs some more work.

It would help if LIBLINEAR.jl is in JuliaML (JuliaML/LIBLINEAR.jl#27).

barucden added a commit to barucden/LIBSVM.jl that referenced this issue Apr 19, 2024
I verified that the added test errors with LIBLINEARv0.6. With
LIBLINEARv0.7, the test passes.

Curiously, LIBLINEAR is only used when fitting LinearSVC through the
"scikit" API (never through `svmtrain`/`svmpredict`).

Resolves JuliaML#98
barucden added a commit that referenced this issue Apr 19, 2024
I verified that the added test errors with LIBLINEARv0.6. With
LIBLINEARv0.7, the test passes.

Curiously, LIBLINEAR is only used when fitting LinearSVC through the
"scikit" API (never through `svmtrain`/`svmpredict`).

Resolves #98
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants