Registry / ai-ml / liblinear-multicore

liblinear-multicore

JSON →
library2.50.0pypypiunverified

liblinear-multicore provides a Python interface to the multi-core LIBLINEAR library, an OpenMP implementation designed to significantly reduce training time for large-scale linear classification, regression, and outlier detection on shared-memory systems. It is actively maintained with the current version 2.50.0 released in December 2025, offering speedups over the official LIBLINEAR in multi-core environments.

pip install liblinear-multicore
INSTALL
IMPORT
SIG · LIBLINEAR-MULTICOR
L
liblinear-multicore
ai-mlpythonv2.50.0
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
build_error
glibc
py 3.103.910 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

* (high-level utilities)
from liblinear.liblinearutil import *
from liblinearutil import *
The import path changed after version 2.43. The old path 'from liblinearutil import *' is incorrect for newer versions.
* (low-level C interfaces)
from liblinear.liblinear import *
For advanced users directly calling C interfaces via ctypes.

This quickstart demonstrates how to train a linear classification model using `liblinear-multicore` with a custom number of threads. It covers creating problem and parameter objects, training the model, making predictions, evaluating results, and saving/loading models. Data can be provided in LIBSVM format or as Python lists/dictionaries/NumPy arrays/SciPy sparse matrices. The `-m` option in the parameter string specifies the number of threads for parallelization.

from liblinear.liblinearutil import * # Example data (LIBSVM format or Python list/dict/ndarray) y = [1, -1, 1, -1] x = [{1:1, 3:1}, {1:-1, 3:-1}, {1:1, 3:1}, {1:-1, 3:-1}] # Create problem and parameter instances # Use '-m nr_thread' option for multi-core training, e.g., '-m 4' for 4 threads prob = problem(y, x) param = parameter('-s 0 -c 4 -m 4') # -s 0: L2-regularized L2-loss SVM (dual), -c 4: cost parameter, -m 4: 4 threads # Train the model m = train(prob, param) # Make predictions p_labels, p_metrics, p_values = predict(y, x, m) # Print results (example for classification) ACC, MSE, SCC = evaluations(y, p_labels) print(f"Accuracy = {ACC[0]:.2f}%") # Save and load model save_model('model_file', m) loaded_m = load_model('model_file')
Debug
Known issues
breakingThe Python import path for high-level utilities changed after version 2.43. Using 'from liblinearutil import *' will fail in newer versions.
fix
Update imports to 'from liblinear.liblinearutil import *'.
affects: >=2.43
gotchaCareless handling of model instances obtained through low-level C interfaces can lead to memory leaks or segmentation faults.
fix
When working with low-level interfaces (from `liblinear.liblinear`), ensure proper memory management. For high-level use (from `liblinear.liblinearutil`), this is generally handled internally.
affects: All versions
gotchaResults from multi-core operations (i.e., when using the '-m' option) may be slightly different when run with a varying number of threads due to the nature of parallel computations.
fix
This is expected behavior and typically results in very similar final objective values. For reproducibility across different thread counts, consider fixing the number of threads or acknowledging potential minor variations.
affects: All versions
gotchaThe `pip install .` or `python setup.py install` commands from the source directory can fail if not executed with specific instructions.
fix
It is recommended to use `pip install liblinear-multicore` for standard installation. If installing from source, consult the official README for specific build instructions, usually involving `pip install -e .` or `pip install --user -e .`.
affects: All versions
gotchaIf the optimization algorithm fails to converge (e.g., in scikit-learn's LogisticRegression with liblinear solver), you might encounter `ConvergenceWarning`.
fix
Consider normalizing your training data (e.g., using `StandardScaler`), tuning regularization parameters (e.g., `C`), or as a last resort, increasing `max_iter`. Setting `dual=False` might also help if the number of features is much larger than the number of samples.
affects: All versions (when used via wrappers that expose convergence warnings)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'liblinear_multicore'
The 'liblinear-multicore' package is not installed in the current Python environment, or the environment is not correctly activated.
fix
Ensure the package is installed using pip: `pip install liblinear-multicore`
ImportError: DLL load failed: The specified module could not be found.
On Windows, this often means required C/C++ runtime libraries (like the Visual C++ Redistributable) are missing. On Linux, it might indicate missing shared object files (`.so`) due to absent system-level dependencies (e.g., OpenMP libraries).
fix
For Windows, install the appropriate Microsoft Visual C++ Redistributable for your Python version. For Linux, install development libraries like `libgomp1` (Debian/Ubuntu: `sudo apt-get install libgomp1`) or other necessary C/C++ runtime dependencies. A clean reinstallation of `liblinear-multicore` in a fresh virtual environment might also resolve the issue.
Segmentation fault (core dumped)
This critical error typically occurs when the underlying C++ LIBLINEAR library encounters a memory access violation. This can be caused by providing malformed input data, incorrect data types (e.g., labels, features), or improper handling of low-level model objects returned by the library.
fix
Carefully check the format and data types of your input arrays (labels `y` and features `x`) to ensure they conform to the expectations of `liblinear-multicore` (e.g., Python lists, NumPy arrays, or SciPy sparse matrices with correct dtypes). If using lower-level interfaces, ensure proper memory management and conversion of `ctypes` pointers to Python model objects as described in the documentation.
Upgrade
Version history
2.50.0latest on PyPI · released Dec 30, 2025
Audit
Dependencies
scipyrequiredRequired for 'Quick Start with Scipy' and various data handling utilities.
numbaoptionalOptional dependency; installing it can significantly speed up some operations.
Agent activity
5 hits · last 30 days
node
4
Resources
liblinear-multicore — pip install liblinear-multicore · libregistry