mlpack_linear_svm(1)
β¨ mlpack_linear_svm β¨
okay so this is the manual page for mlpack_linear_svm(1), and bestie, if you've ever wanted a linear SVM that goes brrr, this is literally it. sit down, hydrate, let's get into it π«Ά
π NAME π
mlpack_linear_svm β linear svm is an l2-regularized support vector machine. no cap. πΈ
π SYNOPSIS π
mlpack_linear_svm [-d double] [-E int] [-m unknown] [-l unknown] [-r double] [-n int] [-N bool] [-c int] [-O string] [-s int] [-S bool] [-a double] [-T unknown] [-L unknown] [-e double] [-t unknown] [-V bool] [-M unknown] [-P unknown] [-p unknown] [-h -v]
π DESCRIPTION π
so this is an implementation of linear SVMs that uses either L-BFGS or parallel SGD (stochastic gradient descent) to train the model. two iconic optimizers, one little program π
here's the whole vibe: this program lets you load a linear SVM model (via the --input_model_file (-m) parameter), train a linear SVM model given training data (specified with the --training_file (-t) parameter), or honestly do both of those things at once, because why choose. on top of that, it lets you do classification on a test dataset (specified with the --test_file (-T) parameter), and the classification results may be saved with the --predictions_file (-P) output parameter. and the trained linear SVM model itself? saved with the --output_model_file (-M) output parameter. slay β¨
the training data, if you specify it, may have class labels as its last dimension. alternately, the --labels_file (-l) parameter may be used to specify a separate vector of labels. your call, both are valid π
when a model is being trained, there are so many options, and we're listing all of them because we keep every detail around here:
- L2 regularization (which exists to prevent overfitting, the enemy) can be specified with the
--lambda (-r)option. - the number of classes can be manually specified with the
--num_classes (-c). - and if an intercept term is not desired in the model, the
--no_intercept (-N)parameter can be specified. - margin of difference between correct class and other classes can be specified with the
--delta (-d)option. - the optimizer used to train the model can be specified with the
--optimizer (-O)parameter. available options arepsgd(parallel stochastic gradient descent) andlbfgs(the L-BFGS optimizer).
there are also various parameters for the optimizer, and yes we're covering them:
- the
--max_iterations (-n)parameter specifies the maximum number of allowed iterations. - the
--tolerance (-e)parameter specifies the tolerance for convergence. - for the parallel SGD optimizer, the
--step_size (-a)parameter controls the step size taken at each iteration by the optimizer, and the maximum number of epochs is specified with--epochs (-E).
β οΈ heads up, and this is important: if the objective function for your data is oscillating between Inf and 0, the step size is probably too large. not a drill. π
there are more parameters for the optimizers, but the C++ interface must be used to access these. so like, iykyk, but that's a whole other door.
optionally, the model can be used to predict the labels for another matrix of data points, if --test_file (-T) is specified. and here's the cute part: the --test_file (-T) parameter can be specified without the --training_file (-t) parameter, so long as an existing linear SVM model is given with the --input_model_file (-m) parameter. the output predictions from the linear SVM model may be saved with the --predictions_file (-P) parameter. π€
π DESCRIPTION: examples that actually eat π
as an example, to train a linear SVM on the data data.csv with labels labels.csv with L2 regularization of 0.1, saving the model to lsvm_model.bin, the following command may be used:
$ mlpack_linear_svm --training_file data.csv --labels_file labels.csv --lambda 0.1 --delta 1 --num_classes 0 --output_model_file lsvm_model.bin
then, to use that model to predict classes for the dataset test.csv, storing the output predictions in predictions.csv, the following command may be used:
$ mlpack_linear_svm --input_model_file lsvm_model.bin --test_file test.csv --predictions_file predictions.csv
literally that easy, main character energy fr fr π
π OPTIONAL INPUT OPTIONS π
one bullet per option, exactly as they come, no skipping, we respect the source π«Ά
--delta (-d)[double] β margin of difference between correct class and other classes. default value1. π«--epochs (-E)[int] β maximum number of full epochs over dataset for psgd. default value50.--help (-h)[bool] β default help info. your little bestie when you're lost π--info[string] β print help on a specific option. default value''.--input_model_file (-m)[unknown] β existing model (parameters).--labels_file (-l)[unknown] β a matrix containing labels (0 or 1) for the points in the training set (y).--lambda (-r)[double] β L2-regularization parameter for training. default value0.0001.--max_iterations (-n)[int] β maximum iterations for optimizer (0 indicates no limit). default value10000.--no_intercept (-N)[bool] β do not add the intercept term to the model.--num_classes (-c)[int] β number of classes for classification; if unspecified (or0), the number of classes found in the labels will be used. default value0.--optimizer (-O)[string] β optimizer to use for training ('lbfgs'or'psgd'). default value'lbfgs'.--seed (-s)[int] β random seed. if0,std::time(NULL)is used. default value0.--shuffle (-S)[bool] β don't shuffle the order in which data points are visited for parallel SGD.--step_size (-a)[double] β step size for parallel SGD optimizer. default value0.01.--test_file (-T)[unknown] β matrix containing test dataset.--test_labels_file (-L)[unknown] β matrix containing test labels.--tolerance (-e)[double] β convergence tolerance for optimizer. default value1e-10.--training_file (-t)[unknown] β a matrix containing the training set (the matrix of predictors, X).--verbose (-v)[bool] β display informational messages and the full list of parameters and timers at the end of execution.--version (-V)[bool] β display the version of mlpack.
π OPTIONAL OUTPUT OPTIONS π
the outputs, the moment we've all been waiting for:
--output_model_file (-M)[unknown] β output for trained linear svm model. β¨--predictions_file (-P)[unknown] β if test data is specified, this matrix is where the predictions for the test set will be saved.--probabilities_file (-p)[unknown] β if test data is specified, this matrix is where the class probabilities for the test set will be saved.
π§ ADDITIONAL INFORMATION π§
for further information, including relevant papers, citations, and theory, consult the documentation found at http://www.mlpack.org or included with your distribution of mlpack. go read it, it's giving scholar π¦
and that's the whole thing bestie! this page came from mlpack-4.8.0, dated 22 June 2026, and yeah it's the mlpack_linear_svm(1) manual. periodt π stay regularized, stay convergent, bye!! πΈβ¨
π¦ where this page comes from
- ubuntu stonking: mlpack-bin 4.8.0-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms