Skip to content

Commit 44d48df

Browse files
authored
Merge pull request #12
Fix the issue where primal solver cannot be used in libmultilabel.
2 parents 5972bee + 2426a2f commit 44d48df

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

libmultilabel/linear/linear.py

Lines changed: 5 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
8+
from liblinear.liblinearutil import train, problem, parameter, solver_names
99
from tqdm import tqdm
1010

1111
__all__ = [
@@ -335,7 +335,8 @@ 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-
param.w_recalc = True # only works for solving L1/L2-SVM dual
338+
if param.solver_type in [solver_names.L2R_L1LOSS_SVC_DUAL, solver_names.L2R_L2LOSS_SVC_DUAL]:
339+
param.w_recalc = True # only works for solving L1/L2-SVM dual
339340
with silent_stderr():
340341
model = train(prob, param)
341342

@@ -597,7 +598,8 @@ def train_binary_and_multiclass(
597598

598599
prob = problem(y, x)
599600
param = parameter(options)
600-
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
601603
with silent_stderr():
602604
model = train(prob, param)
603605

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

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = libmultilabel
3-
version = 0.7.2
3+
version = 0.7.3
44
author = LibMultiLabel Team
55
license = MIT License
66
license_file = LICENSE
@@ -25,7 +25,7 @@ classifiers =
2525
[options]
2626
packages = find:
2727
install_requires =
28-
liblinear-multicore
28+
liblinear-multicore>=2.49.0
2929
numba
3030
pandas>1.3.0
3131
PyYAML

0 commit comments

Comments
 (0)