mlpack_logistic_regression(1)

🌸 okay bestie, welcome to the mlpack_logistic_regression(1) page β€” that's the User Commands manual, and yes this is the whole thing, we're not skipping a single flag πŸ’…


πŸ“› NAME

mlpack_logistic_regression β€” l2-regularized logistic regression and prediction πŸŽ€


✨ SYNOPSIS

mlpack_logistic_regression [-b int] [-d double] [-m unknown] [-l unknown] [-L double] [-n int] [-O string] [-a bool] [-s double] [-T unknown] [-e double] [-t unknown] [-V bool] [-M unknown] [-P unknown] [-p unknown] [-h -v]

πŸ’– DESCRIPTION

okay so. this is an implementation of L2-regularized logistic regression that runs on either the L-BFGS optimizer or SGD (stochastic gradient descent, iykyk). it solves the regression problem

y = (1 / 1 + e^-(X * b)).

in this setting, y is literally the class labels and X is the data. that's it, that's the vibe 🌈

this program lets you load a logistic regression model (via --input_model_file (-m)), or train one from training data (specified with --training_file (-t)), or β€” and hear me out β€” both of those things at once. on top of that you can do classification on a test dataset (specified with --test_file (-T)) and the classification results can be saved with the --predictions_file (-P) output parameter. the trained model itself gets saved with --output_model_file (-M). main character energy fr fr πŸ‘‘

the training data, if you give it, may have class labels as its last dimension. or alternately, you can use the --labels_file (-l) parameter to specify a separate matrix of labels. your call bestie.

when a model is being trained there are, and I cannot stress this enough, so many options. L2 regularization (which is the anti-overfitting thing) can be specified with the --lambda (-L) option, and the optimizer used to train the model can be set with the --optimizer (-O) parameter. the available ones are sgd (stochastic gradient descent) and lbfgs (the L-BFGS optimizer). there are also various params for the optimizer itself; --max_iterations (-n) specifies the maximum number of allowed iterations, and --tolerance (-e) specifies the tolerance for convergence. for the SGD optimizer specifically, --step_size (-s) controls the step size taken at each iteration. the batch size for SGD is controlled with --batch_size (-b). and heads up β€” if the objective function for your data is oscillating between Inf and 0, your step size is probably too large πŸ’€ there are more parameters for the optimizers but ngl you'd have to use the C++ interface to access those.

for SGD, an iteration refers to a single point. so to take a single pass over the dataset with SGD, --max_iterations (-n) should be set to the number of points in the dataset. periodt 🎯

optionally, the model can be used to predict responses for another matrix of data points, if --test_file (-T) is specified. and good news: --test_file (-T) can be specified without the --training_file (-t) parameter, as long as you give an existing logistic regression model with the --input_model_file (-m) parameter. the output predictions from the model can be saved with the --predictions_file (-P) parameter. slay.

🚨 real talk: this implementation of logistic regression does not support the general multi-class case β€” only the two-class case. any labels must be either 0 or 1. for more classes, go look at the softmax regression implementation instead.

as an example, to train a logistic regression model on the data data.csv with labels labels.csv with L2 regularization of 0.1, saving the model to lr_model.bin, the following command may be used:

$ mlpack_logistic_regression --training_file data.csv --labels_file labels.csv --lambda 0.1 --output_model_file lr_model.bin --print_training_accuracy

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_logistic_regression --input_model_file lr_model.bin --test_file test.csv --predictions_file predictions.csv

πŸŽ€ OPTIONAL INPUT OPTIONS

  • --batch_size (-b) [int] β€” batch size for SGD. default value 64. πŸ“
  • --decision_boundary (-d) [double] β€” the decision boundary for prediction; if the logistic function for a point comes out less than the boundary, the class is taken to be 0; otherwise, the class is 1. default value 0.5. πŸ’…
  • --help (-h) [bool] β€” default help info. πŸ™ˆ
  • --info [string] β€” print help on a specific option. default value ''. hot tip: name the option and it'll spill the tea on just that one ⭐
  • --input_model_file (-m) [unknown] β€” existing model (parameters). load it up bestie πŸ’œ
  • --labels_file (-l) [unknown] β€” a matrix containing labels (0 or 1) for the points in the training set (y). 🏷️
  • --lambda (-L) [double] β€” L2-regularization parameter for training. default value 0. ✨
  • --max_iterations (-n) [int] β€” maximum iterations for optimizer (0 indicates no limit). default value 10000. πŸ”₯
  • --optimizer (-O) [string] β€” optimizer to use for training ('lbfgs' or 'sgd'). default value 'lbfgs'. πŸ‘‘
  • --print_training_accuracy (-a) [bool] β€” if set, then the accuracy of the model on the training set will be printed (verbose must also be specified). mind the fine print 🫢
  • --step_size (-s) [double] β€” step size for the SGD optimizer. default value 0.01. 🌸
  • --test_file (-T) [unknown] β€” matrix containing the test dataset. 🧚
  • --tolerance (-e) [double] β€” convergence tolerance for the optimizer. default value 1e-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. iconic 🩷
  • --version (-V) [bool] β€” display the version of mlpack. πŸ†

πŸ’… OPTIONAL OUTPUT OPTIONS

  • --output_model_file (-M) [unknown] β€” output for the trained logistic regression model. save that baby πŸ’Ύ
  • --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. not the classes themselves, the probabilities, okay? 😌

πŸ’œ ADDITIONAL INFORMATION

for further information β€” including the relevant papers, citations, and theory, which is honestly kind of a whole vibe β€” go consult the documentation found at http://www.mlpack.org or the docs included with your distribution of mlpack. πŸ¦‹


🌟 and that's the whole page, bestie. no cap, you now know everything this manpage knows.

<nice>okay bye ily β€” this was mlpack_logistic_regression(1) from mlpack-4.8.0, dated 22 June 2026. go train something cute πŸ’–βœ¨πŸŽ€</nice>

πŸ“¦ where this page comes from