Omar ShritandRyan Curtin ca6c44c269 Data options stage1 (#3927)
* Start porting DataOptions from the previous PR

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Refactor the old implementation

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Import detect_file_type

Signed-off-by: Omar Shrit <omar@avontech.fr>

* import load categorical

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Add utilities and other functions

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Remove more code related to ModelOptions

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Remove other stuff that are ported but not required yet

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Fix a small thing

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Adding additional arma traits for loading csv

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Fix most of the errors

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Port save and implementation and load arff and other funcs

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Fix the errors related to SFINAE according to @rcurtin

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Fix the compiler confusion

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Some hopefully-helpful refactoring of DataOptionsBase.

* Adding SFINAEs to make it pass compilation

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Fix warning related to data_options

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Use move instead of copy

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Debug some failing tests and issues.

* Remove numeric csv, not used

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Fix a couple of bugs observed in tests

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Add segfault comments

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Pass non-const headers to Armadillo so they are actually filled; and clean up combinatorial option-setting.

* Push the code for MissingPolicy

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Fix the first part convert char to nan

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Add datasetMissingPolicy to copy/move constructor/operators.

* All tests are passing, some debugging symbols left

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Remove all debugging symbols

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Fix compilation issue for older Armadillo.

* Oops, fix backwards condition.

* Update src/mlpack/core/data/utilities.hpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>

* Update src/mlpack/core/data/load.hpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>

* Update src/mlpack/core/data/data_options.hpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>

* Update src/mlpack/core/data/load.hpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>

* Update src/mlpack/core/data/load_categorical_impl.hpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>

* Update src/mlpack/core/data/load_impl.hpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>

* Update src/mlpack/core/data/load_impl.hpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>

* Update src/mlpack/core/data/load_impl.hpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>

* Update src/mlpack/core/data/load_impl.hpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>

* Update src/mlpack/core/data/save_impl.hpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>

* Change it to ARFFASCII

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Fix error handling everywhere

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Fix other error handling

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Separate data options classes into three files

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Do not forget to include the headers

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Fix the failing test by removing white spaces for now

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Fix the error message

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Fix LoadARFF

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Bring back SINAE

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Update src/mlpack/core/data/utilities.hpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>

* Update src/mlpack/core/data/load_arff_impl.hpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>

* Update src/mlpack/core/data/load_categorical_impl.hpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>

* Update src/mlpack/core/data/load_impl.hpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>

* Update src/mlpack/core/data/load_impl.hpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>

* Update src/mlpack/core/data/save_impl.hpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>

* Update src/mlpack/core/data/load_impl.hpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>

* Fix style

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Use Fatal Warn

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Fix last comment

Signed-off-by: Omar Shrit <omar@avontech.fr>

* last comment

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Fix declaration error

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Fix last style problems

Signed-off-by: Omar Shrit <omar@avontech.fr>

* Update src/mlpack/core/data/load_arff_impl.hpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>

---------

Signed-off-by: Omar Shrit <omar@avontech.fr>
Co-authored-by: Ryan Curtin <ryan@ratml.org>
2025-05-10 15:08:43 +02:00
2025-04-14 19:25:59 -04:00
2020-11-26 11:02:03 -05:00
2025-02-05 21:06:26 +01:00
2025-05-10 15:08:43 +02:00
2022-09-21 03:40:20 +02:00
2019-06-14 21:34:36 +02:00
2024-12-23 03:59:54 +01:00
2025-04-21 06:04:49 +02:00
2025-04-21 06:04:49 +02:00
2025-02-05 21:06:26 +01:00
2025-04-03 11:47:01 -04:00

mlpack: a fast, header-only machine learning library
a fast, header-only machine learning library

Home | Download | Documentation | Help |

Azure DevOps builds (job) License NumFOCUS

Download: current stable version (4.6.0)

mlpack is an intuitive, fast, and flexible header-only C++ machine learning library with bindings to other languages. It is meant to be a machine learning analog to LAPACK, and aims to implement a wide array of machine learning methods and functions as a "swiss army knife" for machine learning researchers.

mlpack's lightweight C++ implementation makes it ideal for deployment, and it can also be used for interactive prototyping via C++ notebooks (these can be seen in action on mlpack's homepage).

In addition to its powerful C++ interface, mlpack also provides command-line programs, Python bindings, Julia bindings, Go bindings and R bindings.

Quick links:

mlpack uses an open governance model and is fiscally sponsored by NumFOCUS. Consider making a tax-deductible donation to help the project pay for developer time, professional services, travel, workshops, and a variety of other needs.


0. Contents

  1. Citation details
  2. Dependencies
  3. Installation
  4. Usage from C++
    1. Reducing compile time
  5. Building mlpack's test suite
  6. Further resources

1. Citation details

If you use mlpack in your research or software, please cite mlpack using the citation below (given in BibTeX format):

@article{mlpack2023,
    title     = {mlpack 4: a fast, header-only C++ machine learning library},
    author    = {Ryan R. Curtin and Marcus Edel and Omar Shrit and 
                 Shubham Agrawal and Suryoday Basak and James J. Balamuta and 
                 Ryan Birmingham and Kartik Dutt and Dirk Eddelbuettel and 
                 Rishabh Garg and Shikhar Jaiswal and Aakash Kaushik and 
                 Sangyeon Kim and Anjishnu Mukherjee and Nanubala Gnana Sai and 
                 Nippun Sharma and Yashwant Singh Parihar and Roshan Swain and 
                 Conrad Sanderson},
    journal   = {Journal of Open Source Software},
    volume    = {8},
    number    = {82},
    pages     = {5026},
    year      = {2023},
    doi       = {10.21105/joss.05026},
    url       = {https://doi.org/10.21105/joss.05026}
}

Citations are beneficial for the growth and improvement of mlpack.

2. Dependencies

mlpack requires the following additional dependencies:

If the STB library headers are available, image loading support will be available.

If you are compiling Armadillo by hand, ensure that LAPACK and BLAS are enabled.

3. Installation

Detailed installation instructions can be found on the Installing mlpack page.

4. Usage from C++

Once headers are installed with make install, using mlpack in an application consists only of including it. So, your program should include mlpack:

#include <mlpack.hpp>

and when you link, be sure to link against Armadillo. If your example program is my_program.cpp, your compiler is GCC, and you would like to compile with OpenMP support (recommended) and optimizations, compile like this:

g++ -O3 -std=c++17 -o my_program my_program.cpp -larmadillo -fopenmp

Note that if you want to serialize (save or load) neural networks, you should add #define MLPACK_ENABLE_ANN_SERIALIZATION before including <mlpack.hpp>. If you don't define MLPACK_ENABLE_ANN_SERIALIZATION and your code serializes a neural network, a compilation error will occur.

Warning: older versions of OpenBLAS (0.3.26 and older) compiled to use pthreads may use too many threads for computation, causing significant slowdown. OpenBLAS versions compiled with OpenMP do not suffer from this issue. See the test build guide for more details and simple workarounds.

See also:

4.1. Reducing compile time

mlpack is a template-heavy library, and if care is not used, compilation time of a project can be very high. Fortunately, there are a number of ways to reduce compilation time:

  • Include individual headers, like <mlpack/methods/decision_tree.hpp>, if you are only using one component, instead of <mlpack.hpp>. This reduces the amount of work the compiler has to do.

  • Only use the MLPACK_ENABLE_ANN_SERIALIZATION definition if you are serializing neural networks in your code. When this define is enabled, compilation time will increase significantly, as the compiler must generate code for every possible type of layer. (The large amount of extra compilation overhead is why this is not enabled by default.)

  • If you are using mlpack in multiple .cpp files, consider using extern templates so that the compiler only instantiates each template once; add an explicit template instantiation for each mlpack template type you want to use in a .cpp file, and then use extern definitions elsewhere to let the compiler know it exists in a different file.

Other strategies exist too, such as precompiled headers, compiler options, ccache, and others.

5. Building mlpack's test suite

See the installation instruction section.

6. Further Resources

More documentation is available for both users and developers.

To learn about the development goals of mlpack in the short- and medium-term future, see the vision document.

If you have problems, find a bug, or need help, you can try visiting the mlpack help page, or mlpack on Github. Alternately, mlpack help can be found on Matrix at #mlpack; see also the community page.

S
Description
No description provided
Readme
274 MiB
Languages
C++ 89.9%
C 6.6%
CMake 1.7%
Python 0.7%
Shell 0.4%
Other 0.7%