On this page, several simple mlpack examples are contained, in increasing order of complexity. If you compile from the command-line, be sure that your compiler is in C++11 mode. With modern gcc and clang, this should already be the default.
logistic_regression_main.cppfrom the directory
src/mlpack/methods/cannot be compiled easily by hand (the same is true for the individual tests in
src/mlpack/tests/); instead, those should be compiled with CMake, by running, e.g.,
mlpack_test; see Building mlpack From Source. However, any program that uses mlpack (and is not a part of the library itself) can be compiled easily with g++ or clang from the command line.
A simple program to compute the covariance of a data matrix ("data.csv"), assuming that the data is already centered, and save it to file.
This simple program uses the mlpack::neighbor::NeighborSearch object to find the nearest neighbor of each point in a dataset using the L1 metric, and then print the index of the neighbor and the distance of it to stdout.
For more complex examples, it is useful to refer to the main executables, found in
src/mlpack/methods/. A few are listed below.