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. πŸ‘‘

  • -s type β€” sets the type of the solver (default 1). 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 classification
  • 5 ... L1-regularized L2-loss support vector classification
  • 6 ... L1-regularized logistic regression
  • 7 ... 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)
  • -c cost β€” sets the parameter C (default: 1) πŸ’œ
  • -p epsilon β€” sets the epsilon in the loss function of epsilon-SVR (default: 0.1)
  • -e epsilon β€” sets the tolerance of the termination criterion. and the vibe of this one depends entirely on your -s, so pay attention bestie:
    • -s 0 and 2:

|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, 4 and 7:

Dual maximal violation <= epsilon; similar to libsvm (default: 0.1)

  • -s 5 and 6:

|f'(w)|_inf <= epsilon*min(pos,neg)/l*|f'(w0)|_inf, where f is the primal function (default: 0.01)

  • -s 12 and 13:

|f'(alpha)|_1 <= epsilon |f'(alpha0)|, where f is the dual function (default 0.1)

  • -B bias β€” if bias >= 0, then instance x becomes [x; bias]; if bias < 0, then no bias term is added (default: -1) ✨
  • -wi weight β€” weights adjust the parameter C of different classes (peep the README for the deets) πŸ”₯
  • -v n β€” n-fold cross validation mode
  • -C β€” find parameters (C for -s 0, 2 and 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. πŸŽ€βœ¨