{"id":4079,"library":"liblinear-multicore","title":"Python binding of multi-core LIBLINEAR","description":"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.","status":"active","version":"2.50.0","language":"en","source_language":"en","source_url":"https://github.com/cjlin1/liblinear","tags":["machine-learning","svm","linear-classification","multi-core","parallel-computing","liblinear"],"install":[{"cmd":"pip install liblinear-multicore","lang":"bash","label":"Latest stable release"},{"cmd":"pip install -U liblinear-multicore","lang":"bash","label":"Upgrade to latest version"}],"dependencies":[{"reason":"Required for 'Quick Start with Scipy' and various data handling utilities.","package":"scipy","optional":false},{"reason":"Optional dependency; installing it can significantly speed up some operations.","package":"numba","optional":true}],"imports":[{"note":"The import path changed after version 2.43. The old path 'from liblinearutil import *' is incorrect for newer versions.","wrong":"from liblinearutil import *","symbol":"* (high-level utilities)","correct":"from liblinear.liblinearutil import *"},{"note":"For advanced users directly calling C interfaces via ctypes.","symbol":"* (low-level C interfaces)","correct":"from liblinear.liblinear import *"}],"quickstart":{"code":"from liblinear.liblinearutil import *\n\n# Example data (LIBSVM format or Python list/dict/ndarray)\ny = [1, -1, 1, -1]\nx = [{1:1, 3:1}, {1:-1, 3:-1}, {1:1, 3:1}, {1:-1, 3:-1}]\n\n# Create problem and parameter instances\n# Use '-m nr_thread' option for multi-core training, e.g., '-m 4' for 4 threads\nprob = problem(y, x)\nparam = parameter('-s 0 -c 4 -m 4') # -s 0: L2-regularized L2-loss SVM (dual), -c 4: cost parameter, -m 4: 4 threads\n\n# Train the model\nm = train(prob, param)\n\n# Make predictions\np_labels, p_metrics, p_values = predict(y, x, m)\n\n# Print results (example for classification)\nACC, MSE, SCC = evaluations(y, p_labels)\nprint(f\"Accuracy = {ACC[0]:.2f}%\")\n\n# Save and load model\nsave_model('model_file', m)\nloaded_m = load_model('model_file')","lang":"python","description":"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."},"warnings":[{"fix":"Update imports to 'from liblinear.liblinearutil import *'.","message":"The Python import path for high-level utilities changed after version 2.43. Using 'from liblinearutil import *' will fail in newer versions.","severity":"breaking","affected_versions":">=2.43"},{"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.","message":"Careless handling of model instances obtained through low-level C interfaces can lead to memory leaks or segmentation faults.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Results 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.","severity":"gotcha","affected_versions":"All versions"},{"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 .`.","message":"The `pip install .` or `python setup.py install` commands from the source directory can fail if not executed with specific instructions.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"If the optimization algorithm fails to converge (e.g., in scikit-learn's LogisticRegression with liblinear solver), you might encounter `ConvergenceWarning`.","severity":"gotcha","affected_versions":"All versions (when used via wrappers that expose convergence warnings)"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}