Lemga: Learning Models and Generic Algorithms

Copyright (C) 2001-2006 Ling Li

Lemga is a C++ package which consists of classes for several learning models and generic algorithms for optimizing (training) the models. It was derived from my old code for a CS156b project Letter Recognition.

Models and algorithms currently coded are:

Lemga has been used in several of my own research projects with GCC 2.96--3.4.x in Linux. However, it also works with GCC 3.0.x and 3.2.x (Solaris), ICC 8 (Linux), and Visual C++.NET (Windows).


Warning: The source code and manual of Lemga shared on this page are exclusively for CS/CNS/EE 156b class use. If you want to use it for other reasons, please ask for my permission.

The source code is provided as is with no warranty. Feel free to modify the code to your need. Comments, suggestions, and bug reports are all welcome!

Datasets in format compatible to LEMGA can be found at my data page.


Here are some slides on Lemga: Brief Introduction to LEMGA by Hsuan-Tien based on his experience as a user, and Introduction with Examples (updated to 0.1 beta, 2003) by me.

Note that you have to write your own main file to use classes in Lemga. The latest version contains examples in test/. See test/README for more details.

To use SVM in LEMGA, LIBSVM is required and has to be patched to support weighted training examples. The steps are:

  1. Download LIBSVM and patch it. Alternatively, you can directly download the patched LIBSVM from links above.
  2. Update variable LIBSVM in lemga/Makefile so that the compiler knows where to find LIBSVM source.

To use LPBoost in LEMGA, the GNU Linear Programming Kit is required.


  1. Add more detailed documentation
  2. Add more learning models
  3. Ease/unify the way to specify options

Other Resources

Since my code was basically for my own use, it is not as robust and complete as some other software packages I found from the Internet. I listed them here in hope you will find a more suitable one for your project.

List of machine learning software; More software at MLnet.