Skip to content

Fix the issue where primal solver cannot be used in libmultilabel. #12

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

Merged
merged 3 commits into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions libmultilabel/linear/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import numpy as np
import scipy.sparse as sparse
from liblinear.liblinearutil import train, problem, parameter
from liblinear.liblinearutil import train, problem, parameter, solver_names
from tqdm import tqdm

__all__ = [
Expand Down Expand Up @@ -335,7 +335,8 @@ def _do_train(y: np.ndarray, x: sparse.csr_matrix, options: str) -> np.matrix:

prob = problem(y, x)
param = parameter(options)
param.w_recalc = True # only works for solving L1/L2-SVM dual
if param.solver_type in [solver_names.L2R_L1LOSS_SVC_DUAL, solver_names.L2R_L2LOSS_SVC_DUAL]:
param.w_recalc = True # only works for solving L1/L2-SVM dual
with silent_stderr():
model = train(prob, param)

Expand Down Expand Up @@ -597,7 +598,8 @@ def train_binary_and_multiclass(

prob = problem(y, x)
param = parameter(options)
param.w_recalc = True
if param.solver_type in [solver_names.L2R_L1LOSS_SVC_DUAL, solver_names.L2R_L2LOSS_SVC_DUAL]:
param.w_recalc = True
with silent_stderr():
model = train(prob, param)

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
liblinear-multicore
liblinear-multicore>=2.49.0
numba
pandas>1.3.0
PyYAML
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = libmultilabel
version = 0.7.2
version = 0.7.3
author = LibMultiLabel Team
license = MIT License
license_file = LICENSE
Expand All @@ -25,7 +25,7 @@ classifiers =
[options]
packages = find:
install_requires =
liblinear-multicore
liblinear-multicore>=2.49.0
numba
pandas>1.3.0
PyYAML
Expand Down