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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 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, L2R_L2LOSS_SVC_DUAL, L2R_L1LOSS_SVC_DUAL
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 [L2R_L1LOSS_SVC_DUAL, 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