LIBLINEAR-TRAIN(1)
π liblinear-train(1) π
okay so this is the General Commands Manual page for liblinear-train, and bestie, it's giving "train a whole classifier in one command" energy and I am obsessed. π
β¨ NAME β¨
liblinear-train β train a linear classifier and produce a model πΈ
β¨ SYNOPSIS β¨
liblinear-train [options] training_set_file [model_file]
β¨ DESCRIPTION β¨
So basically liblinear-train trains a linear classifier using liblinear and spits out a model that's all ready to be used with liblinear-predict(1). slay. π
training_set_file is, like, the file holding the data you're training on. model_file is where the model gets saved β and if you don't hand over a model_file, it lowkey just defaults to training_set_file.model. convenient fr fr π«Ά
Also real talk: sometimes you gotta scale your data to get good performance. That's what svm-scale(1) is for. no cap. β
β¨ OPTIONS β¨
Here's the rundown of every option, bestie, all of them, we're not skipping a single one. π
-stype β sets the type of the solver (default1). and here's the full menu:
for multi-class classification π
0... L2-regularized logistic regression (primal)1... L2-regularized L2-loss support vector classification (dual)2... L2-regularized L2-loss support vector classification (primal)3... L2-regularized L1-loss support vector classification (dual)4... multi-class support vector classification5... L1-regularized L2-loss support vector classification6... L1-regularized logistic regression7... L2-regularized logistic regression (dual)
for regression π
11... L2-regularized L2-loss support vector regression (primal)12... L2-regularized L2-loss support vector regression (dual)13... L2-regularized L1-loss support vector regression (dual)
-ccost β sets the parameter C (default:1) π-pepsilon β sets the epsilon in the loss function of epsilon-SVR (default:0.1)-eepsilon β sets the tolerance of the termination criterion. and the vibe of this one depends entirely on your-s, so pay attention bestie:-s 0and2:
|f'(w)|_2 <= epsilon*min(pos,neg)/l*|f'(w0)|_2, where f is the primal function and pos/neg are the number of positive/negative data (default: 0.01)
-s 11:
|f'(w)|_2 <= epsilon*|f'(w0)|_2 (default 0.0001)
-s 1,3,4and7:
Dual maximal violation <= epsilon; similar to libsvm (default: 0.1)
-s 5and6:
|f'(w)|_inf <= epsilon*min(pos,neg)/l*|f'(w0)|_inf, where f is the primal function (default: 0.01)
-s 12and13:
|f'(alpha)|_1 <= epsilon |f'(alpha0)|, where f is the dual function (default 0.1)
-Bbias β if bias >= 0, then instance x becomes[x; bias]; if bias < 0, then no bias term is added (default:-1) β¨-wiweight β weights adjust the parameter C of different classes (peep the README for the deets) π₯-vn β n-fold cross validation mode-Cβ find parameters (C for-s 0,2and C, p for-s 11) π-qβ Quiet mode (no outputs).
Option -v randomly splits the data into n parts and calculates cross validation accuracy on them. π²
Option -C conducts cross validation under different parameters and finds the best one. it's only supported by -s 0, -s 2 (for finding C) and -s 11 (for finding C, p). and if you don't specify a solver at all? -s 2 gets used. periodt. π
β¨ EXAMPLES β¨
Train a linear SVM using L2-loss function:
liblinear-train data_file
Train a logistic regression model:
liblinear-train -s 0 data_file
Do five-fold cross-validation using L2-loss SVM, using a smaller stopping tolerance 0.001 instead of the default 0.1 for more accurate solutions:
liblinear-train -v 5 -e 0.001 data_file
Conduct cross validation many times by L2-loss SVM and find the parameter C which achieves the best cross validation accuracy:
train -C datafile
For parameter selection by -C, users can specify other solvers (currently -s 0, -s 2 and -s 11 are supported) and different number of CV folds. Further, users can use the -c option to specify the smallest C value of the search range. This option is useful when users want to rerun the parameter selection procedure from a specified C under a different setting, such as a stricter stopping tolerance -e 0.0001 in the above example. Similarly, for -s 11, users can use the -p option to specify the maximal p value of the search range.
train -C -s 0 -v 3 -c 0.5 -e 0.0001 datafile
Train four classifiers:
positive negative Cp Cn
class 1 class 2,3,4 20 10
class 2 class 1,3,4 50 10
class 3 class 1,2,4 20 10
class 4 class 1,2,3 10 10
liblinear-train -c 10 -w1 2 -w2 5 -w3 2 four_class_data_file
If there are only two classes, we train ONE model. The C values for the two classes are 10 and 50:
liblinear-train -c 10 -w3 1 -w2 5 two_class_data_file
Output probability estimates (for logistic regression only) using liblinear-predict(1):
liblinear-predict -b 1 test_file data_file.model output_file
β¨ SEE ALSO β¨
liblinear-predict(1), svm-predict(1), svm-train(1), svm-scale(1) π¦
β¨ AUTHORS β¨
liblinear-train was written by the LIBLINEAR authors at National Taiwan university for the LIBLINEAR Project. π
This manual page was written by Christian Kastner <ckk@debian.org> for the Debian project (and may be used by others).
okay that's the whole page bestie, you ate it, go train something iconic ππ
source/version: LIBLINEAR-TRAIN(1) β and the date on this lil masterpiece is October 21, 2019. iykyk. πβ¨
π¦ where this page comes from
- debian bookworm: liblinear-tools 2.3.0+dfsg-5 Β· BSD-3-Clause
- debian trixie: liblinear-tools 2.3.0+dfsg-5+b2 Β· BSD-3-Clause
- ubuntu jammy: liblinear-tools 2.3.0+dfsg-5 Β· BSD-3-Clause
- ubuntu noble: liblinear-tools 2.3.0+dfsg-5build1 Β· BSD-3-Clause
- ubuntu questing: liblinear-tools 2.3.0+dfsg-5build1
- ubuntu resolute: liblinear-tools 2.3.0+dfsg-5build2 Β· BSD-3-Clause
- ubuntu stonking: liblinear-tools 2.3.0+dfsg-5build2 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms