Skip to content

Commit 8c1b5e1

Browse files
committed
Enable the primal solver support.
1 parent 25ad033 commit 8c1b5e1

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

libmultilabel/linear/linear.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import numpy as np
77
import scipy.sparse as sparse
8-
from liblinear.liblinearutil import train, problem, parameter, L2R_L2LOSS_SVC_DUAL, L2R_L1LOSS_SVC_DUAL
8+
from liblinear.liblinearutil import train, problem, parameter, solver_names
99
from tqdm import tqdm
1010

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

336336
prob = problem(y, x)
337337
param = parameter(options)
338-
if param.solver_type in [L2R_L1LOSS_SVC_DUAL, L2R_L2LOSS_SVC_DUAL]:
338+
if param.solver_type in [solver_names.L2R_L1LOSS_SVC_DUAL, solver_names.L2R_L2LOSS_SVC_DUAL]:
339339
param.w_recalc = True # only works for solving L1/L2-SVM dual
340340
with silent_stderr():
341341
model = train(prob, param)
@@ -598,7 +598,8 @@ def train_binary_and_multiclass(
598598

599599
prob = problem(y, x)
600600
param = parameter(options)
601-
param.w_recalc = True
601+
if param.solver_type in [solver_names.L2R_L1LOSS_SVC_DUAL, solver_names.L2R_L2LOSS_SVC_DUAL]:
602+
param.w_recalc = True
602603
with silent_stderr():
603604
model = train(prob, param)
604605

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
liblinear-multicore
1+
liblinear-multicore>=2.49.0
22
numba
33
pandas>1.3.0
44
PyYAML

0 commit comments

Comments
 (0)