The Library Algorithms API Wrappers Bayesian Nets Compression Containers Graph Tools Image Processing Linear Algebra Machine Learning Metaprogramming Miscellaneous Networking Optimization Parsing Help/Info Examples: C++ Assignment_Learning Base64_Encoder Bayesian_Network Bayesian_Network_From_Disk Bayesian_Network_GUI Bridge BSP Cmd_Line_Parser Compress_Stream Config_File_Reader Custom_Trainers Directory_Navigation Empirical_Kernel_Map Face_Detection FHOG_Feature_Extraction FHOG_Object_Detection Graph_Labeling GUI HTTP_Server Image IO Socket Streams IO Streams Server Kernel_Centroid Kernel_K-Means_Clustering Kernel_Ridge_Regression Kernel_RLS_Filtering Kernel_RLS_Regression KRR_Classification Learning_to_Track Linear_Manifold_Regularizer Logger Logger_Advanced Matrix Matrix_Expressions Member_Function_Pointer Model_Selection Multiclass_Classification Multithreaded_Object Neural_Network Non-Linear Least Squares Numerical_Integration Object_Detector Object_Detector_Advanced One_Class_Classifiers Online_SVM Optimization Parallel_For_Loops Pipe Pipe_2 Quantum_Computing Queue Rank_Features Relevance_Vector_Classification Relevance_Vector_Regression Running_Stats Sequence_Labeling Sequence_Segmentation Sockets Sockstreambuf Sparse_Vectors Std_C++_Allocator Structural_Support_Vector_Machines Support_Vector_Machine Support_Vector_Regression SURF SVM-Rank Threaded_Object Threads Thread_Function Thread_Pool Timer Train_Object_Detector Using_Custom_Kernels XML_Parser Examples: Python Face_Detector Linear_Assignment_Problems Sequence_Segmenter Structural_Support_Vector_Machines SVM-Rank Train_Object_Detector FAQ Home How to compile How to contribute Index Introduction License Python API Suggested Books Current Release Change Log Release Notes Version: 18.7 |
Last Modified: Mar 02, 2014
| # Machine Learning A major design goal of this portion of the library is to provide a highly modular and simple architecture for dealing with kernel algorithms. Towards this end, dlib takes a generic programming approach using C++ templates. In particular, each algorithm is parameterized to allow a user to supply either one of the predefined dlib kernels (e.g. RBF operating on column vectors), or a new user defined kernel. Moreover, the implementations of the algorithms are totally separated from the data on which they operate. This makes the dlib implementation generic enough to operate on any kind of data, be it column vectors, images, or some other form of structured data. All that is necessary is an appropriate kernel. ### Paper Describing dlib Machine Learning
    Davis E. King. Dlib-ml: A Machine Learning Toolkit.
       Journal of Machine Learning Research 10, pp. 1755-1758, 2009

    @Article{dlib09,
      author = {Davis E. King},
      title = {Dlib-ml: A Machine Learning Toolkit},
      journal = {Journal of Machine Learning Research},
      year = {2009},
      volume = {10},
      pages = {1755-1758},
    }
## Primary Algorithms Binary Classification rvm_trainer svm_c_ekm_trainer svm_c_linear_dcd_trainer svm_c_linear_trainer svm_c_trainer svm_nu_trainer svm_pegasos train_probabilistic_decision_function Multiclass Classification one_vs_all_trainer one_vs_one_trainer svm_multiclass_linear_trainer Regression krls krr_trainer mlp rbf_network_trainer rls rr_trainer rvm_regression_trainer svr_linear_trainer svr_trainer Structured Prediction Core Tools structural_svm_problem structural_svm_problem_threaded svm_struct_controller_node svm_struct_processing_node Problem Instances structural_svm_assignment_problem structural_svm_graph_labeling_problem structural_svm_object_detection_problem structural_svm_sequence_labeling_problem structural_assignment_trainer structural_graph_labeling_trainer structural_object_detection_trainer structural_sequence_labeling_trainer structural_sequence_segmentation_trainer structural_track_association_trainer svm_rank_trainer Clustering chinese_whispers find_clusters_using_kmeans kkmeans modularity nearest_center newman_cluster pick_initial_centers Unsupervised cca empirical_kernel_map kcentroid linearly_independent_subset_finder sammon_projection svm_one_class_trainer vector_normalizer vector_normalizer_pca Semi-Supervised/Metric Learning discriminant_pca linear_manifold_regularizer vector_normalizer_frobmetric Feature Selection rank_features rank_unlabeled_training_samples sort_basis_vectors ## Other Tools Validation average_precision cross_validate_assignment_trainer cross_validate_graph_labeling_trainer cross_validate_multiclass_trainer cross_validate_object_detection_trainer cross_validate_ranking_trainer cross_validate_regression_trainer cross_validate_sequence_labeler cross_validate_sequence_segmenter cross_validate_track_association_trainer cross_validate_trainer cross_validate_trainer_threaded test_assignment_function test_binary_decision_function test_graph_labeling_function test_multiclass_decision_function test_object_detection_function test_ranking_function test_regression_function test_sequence_labeler test_sequence_segmenter test_track_association_function Trainer Adapters batch batch_cached null_trainer probabilistic reduced reduced2 roc_c1_trainer roc_c2_trainer verbose_batch verbose_batch_cached Kernels histogram_intersection_kernel linear_kernel offset_kernel polynomial_kernel radial_basis_kernel sigmoid_kernel sparse_histogram_intersection_kernel sparse_linear_kernel sparse_polynomial_kernel sparse_radial_basis_kernel sparse_sigmoid_kernel Function Objects assignment_function decision_function distance_function graph_labeler multiclass_linear_decision_function normalized_function one_vs_all_decision_function one_vs_one_decision_function probabilistic_decision_function probabilistic_function projection_function sequence_labeler sequence_segmenter track_association_function Data IO fix_nonzero_indexing load_image_dataset load_image_dataset_metadata load_libsvm_formatted_data save_image_dataset_metadata save_libsvm_formatted_data Miscellaneous approximate_distance_function compute_mean_squared_distance count_ranking_inversions fill_lisf find_gamma_with_big_centroid_gap is_assignment_problem is_binary_classification_problem is_forced_assignment_problem is_graph_labeling_problem is_learning_problem is_ranking_problem is_sequence_labeling_problem is_sequence_segmentation_problem is_track_association_problem kernel_matrix learn_platt_scaling randomize_samples ranking_pair select_all_distinct_labels simplify_linear_decision_function |

[top]

# approximate_distance_function

This function attempts to find a distance_function object which is close to a target distance_function. That is, it searches for an X such that target(X) is minimized. Critically, X may be set to use fewer basis vectors than the target.

The optimization begins with an initial guess supplied by the user and searches for an X which locally minimizes target(X). Since this problem can have many local minima the quality of the starting point can significantly influence the results.

`#include <dlib/svm.h>`
Detailed Documentation
[top]

# assignment_function

This object is a tool for solving the optimal assignment problem given a user defined method for computing the quality of any particular assignment.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: assignment_learning_ex.cpp
[top]

# average_precision

This function computes the average precision of a ranking.
`#include <dlib/statistics.h>`
Detailed Documentation
[top]

# batch

This is a convenience function for creating batch_trainer objects.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_pegasos_ex.cpp
[top]

# batch_cached

This is a convenience function for creating batch_trainer objects that are setup to use a kernel matrix cache.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# batch_trainer

This is a batch trainer object that is meant to wrap online trainer objects that create decision_functions. It turns an online learning algorithm such as svm_pegasos into a batch learning object. This allows you to use objects like svm_pegasos with functions (e.g. cross_validate_trainer) that expect batch mode training objects.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# cca

This function performs a canonical correlation analysis between two sets of vectors. Additionally, it is designed to be very fast, even for large datasets of over a million high dimensional vectors.
`#include <dlib/statistics.h>`
Detailed Documentation
[top]

# chinese_whispers

This function performs the clustering algorithm described in the paper

> Chinese Whispers - an Efficient Graph Clustering Algorithm and its Application to Natural Language Processing Problems by Chris Biemann.

In particular, this is a method for automatically clustering the nodes in a graph into groups. The method is able to automatically determine the number of clusters.
`#include <dlib/clustering.h>`
Detailed Documentation
[top]

# compute_mean_squared_distance

This is a function that simply finds the average squared distance between all pairs of a set of data samples. It is often convenient to use the reciprocal of this value as the estimate of the gamma parameter of the radial_basis_kernel.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# count_ranking_inversions

Given two sets of objects, X and Y, and an ordering relationship defined between their elements, this function counts how many times we see an element in the set Y ordered before an element in the set X. Additionally, this routine executes efficiently in O(n*log(n)) time via the use of quick sort.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# cross_validate_assignment_trainer

Performs k-fold cross validation on a user supplied assignment trainer object such as the structural_assignment_trainer and returns the fraction of assignments predicted correctly.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: assignment_learning_ex.cpp
[top]

# cross_validate_graph_labeling_trainer

Performs k-fold cross validation on a user supplied graph labeling trainer object such as the structural_graph_labeling_trainer and returns the fraction of assignments predicted correctly.
`#include <dlib/svm_threaded.h>`
Detailed Documentation
C++ Example Programs: graph_labeling_ex.cpp
[top]

# cross_validate_multiclass_trainer

Performs k-fold cross validation on a user supplied multiclass classification trainer object such as the one_vs_one_trainer. The result is described by a confusion matrix.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: multiclass_classification_ex.cpp, custom_trainer_ex.cpp
[top]

# cross_validate_object_detection_trainer

Performs k-fold cross validation on a user supplied object detection trainer such as the structural_object_detection_trainer and returns the precision and recall.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: object_detector_ex.cpp, object_detector_advanced_ex.cpp, train_object_detector.cpp
[top]

# cross_validate_ranking_trainer

Performs k-fold cross validation on a user supplied ranking trainer object such as the svm_rank_trainer and returns the fraction of ranking pairs ordered correctly as well as the mean average precision.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_rank_ex.cpp
Python Example Programs: svm_rank.py
[top]

# cross_validate_regression_trainer

Performs k-fold cross validation on a user supplied regression trainer object such as the svr_trainer and returns the mean squared error and R-squared value.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svr_ex.cpp
[top]

# cross_validate_sequence_labeler

Performs k-fold cross validation on a user supplied sequence labeling trainer object such as the structural_sequence_labeling_trainer and returns a confusion matrix describing the results.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: sequence_labeler_ex.cpp
[top]

# cross_validate_sequence_segmenter

Performs k-fold cross validation on a user supplied sequence segmentation trainer object such as the structural_sequence_segmentation_trainer and returns the resulting precision, recall, and F1-score.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: sequence_segmenter_ex.cpp
Python Example Programs: sequence_segmenter.py,
[top]

# cross_validate_track_association_trainer

Performs k-fold cross validation on a user supplied track association trainer object such as the structural_track_association_trainer and returns the fraction of detections which were correctly associated to their tracks.
`#include <dlib/svm_threaded.h>`
Detailed Documentation
C++ Example Programs: learning_to_track_ex.cpp
[top]

# cross_validate_trainer

Performs k-fold cross validation on a user supplied binary classification trainer object such as the svm_nu_trainer or rbf_network_trainer.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_ex.cpp, model_selection_ex.cpp
[top]

# cross_validate_trainer_threaded

Performs k-fold cross validation on a user supplied binary classification trainer object such as the svm_nu_trainer or rbf_network_trainer. This function does the same thing as cross_validate_trainer except this function also allows you to specify how many threads of execution to use. So you can use this function to take advantage of a multi-core system to perform cross validation faster.
`#include <dlib/svm_threaded.h>`
Detailed Documentation
[top]

# decision_function

This object represents a classification or regression function that was learned by a kernel based learning algorithm. Therefore, it is a function object that takes a sample object and returns a scalar value.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_ex.cpp
[top]

# discriminant_pca

This object implements the Discriminant PCA technique described in the paper:

> A New Discriminant Principal Component Analysis Method with Partial Supervision (2009) by Dan Sun and Daoqiang Zhang

This algorithm is basically a straightforward generalization of the classical PCA technique to handle partially labeled data. It is useful if you want to learn a linear dimensionality reduction rule using a bunch of data that is partially labeled.
`#include <dlib/statistics.h>`
Detailed Documentation
[top]

# distance_function

This object represents a point in kernel induced feature space. You may use this object to find the distance from the point it represents to points in input space as well as other points represented by distance_functions.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# empirical_kernel_map

This object represents a map from objects of sample_type (the kind of object a kernel function operates on) to finite dimensional column vectors which represent points in the kernel feature space defined by whatever kernel is used with this object.

To use the empirical_kernel_map you supply it with a particular kernel and a set of basis samples. After that you can present it with new samples and it will project them into the part of kernel feature space spanned by your basis samples.

This means the empirical_kernel_map is a tool you can use to very easily kernelize any algorithm that operates on column vectors. All you have to do is select a set of basis samples and then use the empirical_kernel_map to project all your data points into the part of kernel feature space spanned by those basis samples. Then just run your normal algorithm on the output vectors and it will be effectively kernelized.

Regarding methods to select a set of basis samples, if you are working with only a few thousand samples then you can just use all of them as basis samples. Alternatively, the linearly_independent_subset_finder often works well for selecting a basis set. I also find that picking a random subset typically works well.

`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: empirical_kernel_map_ex.cpp, linear_manifold_regularizer_ex.cpp
[top]

# fill_lisf

This is a simple function for filling a linearly_independent_subset_finder with data points by using random sampling.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: empirical_kernel_map_ex.cpp
[top]

# find_clusters_using_kmeans

This is just a simple linear kmeans clustering implementation.
`#include <dlib/clustering.h>`
Detailed Documentation
[top]

# find_gamma_with_big_centroid_gap

This is a function that tries to pick a reasonable default value for the gamma parameter of the radial_basis_kernel. It picks the parameter that gives the largest separation between the centroids, in kernel feature space, of two classes of data.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: rank_features_ex.cpp
[top]

# fix_nonzero_indexing

This is a simple function that takes a std::vector of sparse vectors and makes sure they are zero-indexed (e.g. makes sure the first index value is zero).
`#include <dlib/data_io.h>`
Detailed Documentation
[top]

# graph_labeler

This object is a tool for labeling each node in a graph with a value of true or false, subject to a labeling consistency constraint between nodes that share an edge. In particular, this object is useful for representing a graph labeling model learned via some machine learning method, such as the structural_graph_labeling_trainer.
`#include <dlib/graph_cuts.h>`
Detailed Documentation
C++ Example Programs: graph_labeling_ex.cpp
[top]

# histogram_intersection_kernel

This object represents a histogram intersection kernel for use with kernel learning machines.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# is_assignment_problem

This function takes a set of training data for an assignment problem and reports back if it could possibly be a well formed assignment problem.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# is_binary_classification_problem

This function simply takes two vectors, the first containing feature vectors and the second containing labels, and reports back if the two could possibly contain data for a well formed classification problem.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# is_forced_assignment_problem

This function takes a set of training data for a forced assignment problem and reports back if it could possibly be a well formed forced assignment problem.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# is_graph_labeling_problem

This function takes a set of training data for a graph labeling problem and reports back if it could possibly be a well formed problem.
`#include <dlib/svm_threaded.h>`
Detailed Documentation
[top]

# is_learning_problem

This function simply takes two vectors, the first containing feature vectors and the second containing labels, and reports back if the two could possibly contain data for a well formed learning problem. In this case it just means that the two vectors have the same length and aren't empty.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# is_ranking_problem

This function takes a set of training data for a learning-to-rank problem and reports back if it could possibly be a well formed problem.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# is_sequence_labeling_problem

This function takes a set of training data for a sequence labeling problem and reports back if it could possibly be a well formed sequence labeling problem.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# is_sequence_segmentation_problem

This function takes a set of training data for a sequence segmentation problem and reports back if it could possibly be a well formed sequence segmentation problem.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# is_track_association_problem

This function takes a set of training data for a track association learning problem and reports back if it could possibly be a well formed track association problem.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# kcentroid

This object represents a weighted sum of sample points in a kernel induced feature space. It can be used to kernelize any algorithm that requires only the ability to perform vector addition, subtraction, scalar multiplication, and inner products.

An example use of this object is as an online algorithm for recursively estimating the centroid of a sequence of training points. This object then allows you to compute the distance between the centroid and any test points. So you can use this object to predict how similar a test point is to the data this object has been trained on (larger distances from the centroid indicate dissimilarity/anomalous points).

The object internally keeps a set of "dictionary vectors" that are used to represent the centroid. It manages these vectors using the sparsification technique described in the paper The Kernel Recursive Least Squares Algorithm by Yaakov Engel. This technique allows us to keep the number of dictionary vectors down to a minimum. In fact, the object has a user selectable tolerance parameter that controls the trade off between accuracy and number of stored dictionary vectors.

`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: kcentroid_ex.cpp
[top]

# kernel_matrix

This is a simple set of functions that makes it easy to turn a kernel object and a set of samples into a kernel matrix. It takes these two things and returns a matrix expression that represents the kernel matrix.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# kkmeans

This is an implementation of a kernelized k-means clustering algorithm. It performs k-means clustering by using the kcentroid object.

If you want to use the linear kernel (i.e. do a normal k-means clustering) then you should use the find_clusters_using_kmeans routine.

`#include <dlib/clustering.h>`
Detailed Documentation
C++ Example Programs: kkmeans_ex.cpp
[top]

# krls

This is an implementation of the kernel recursive least squares algorithm described in the paper The Kernel Recursive Least Squares Algorithm by Yaakov Engel.

The long and short of this algorithm is that it is an online kernel based regression algorithm. You give it samples (x,y) and it learns the function f(x) == y. For a detailed description of the algorithm read the above paper.

Note that if you want to use the linear kernel then you would be better off using the rls object as it is optimized for this case.

`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: krls_ex.cpp, krls_filter_ex.cpp
[top]

# krr_trainer

Performs kernel ridge regression and outputs a decision_function that represents the learned function.

The implementation is done using the empirical_kernel_map and linearly_independent_subset_finder to kernelize the rr_trainer object. Thus it allows you to run the algorithm on large datasets and obtain sparse outputs. It is also capable of automatically estimating its regularization parameter using leave-one-out cross-validation.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: krr_regression_ex.cpp, krr_classification_ex.cpp
[top]

# learn_platt_scaling

This function is an implementation of the algorithm described in the following papers:

> Probabilistic Outputs for Support Vector Machines and Comparisons to Regularized Likelihood Methods by John C. Platt. March 26, 1999
> A Note on Platt's Probabilistic Outputs for Support Vector Machines by Hsuan-Tien Lin, Chih-Jen Lin, and Ruby C. Weng

This function is the tool used to implement the train_probabilistic_decision_function routine.

`#include <dlib/svm.h>`
Detailed Documentation
[top]

# linearly_independent_subset_finder

This is an implementation of an online algorithm for recursively finding a set (aka dictionary) of linearly independent vectors in a kernel induced feature space. To use it you decide how large you would like the dictionary to be and then you feed it sample points.

The implementation uses the Approximately Linearly Dependent metric described in the paper The Kernel Recursive Least Squares Algorithm by Yaakov Engel to decide which points are more linearly independent than others. The metric is simply the squared distance between a test point and the subspace spanned by the set of dictionary vectors.

Each time you present this object with a new sample point it calculates the projection distance and if it is sufficiently large then this new point is included into the dictionary. Note that this object can be configured to have a maximum size. Once the max dictionary size is reached each new point kicks out a previous point. This is done by removing the dictionary vector that has the smallest projection distance onto the others. That is, the "least linearly independent" vector is removed to make room for the new one.

`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: empirical_kernel_map_ex.cpp
[top]

# linear_kernel

This object represents a linear function kernel for use with kernel learning machines.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# linear_manifold_regularizer

Many learning algorithms attempt to minimize a function that, at a high level, looks like this:

       f(w) == complexity + training_set_error

The idea is to find the set of parameters, w, that gives low error on your training data but also is not "complex" according to some particular measure of complexity. This strategy of penalizing complexity is usually called regularization.

In the above setting, all the training data consists of labeled samples. However, it would be nice to be able to benefit from unlabeled data. The idea of manifold regularization is to extract useful information from unlabeled data by first defining which data samples are "close" to each other (perhaps by using their 3 nearest neighbors) and then adding a term to the above function that penalizes any decision rule which produces different outputs on data samples which we have designated as being close.

It turns out that it is possible to transform these manifold regularized learning problems into the normal form shown above by applying a certain kind of preprocessing to all our data samples. Once this is done we can use a normal learning algorithm, such as the svm_c_linear_trainer, on just the labeled data samples and obtain the same output as the manifold regularized learner would have produced.

The linear_manifold_regularizer is a tool for creating this preprocessing transformation. In particular, the transformation is linear. That is, it is just a matrix you multiply with all your samples. For a more detailed discussion of this topic you should consult the following paper. In particular, see section 4.2. This object computes the inverse T matrix described in that section.

> Linear Manifold Regularization for Large Scale Semi-supervised Learning by Vikas Sindhwani, Partha Niyogi, and Mikhail Belkin

`#include <dlib/manifold_regularization.h>`
Detailed Documentation
C++ Example Programs: linear_manifold_regularizer_ex.cpp
[top]

# load_image_dataset

This is a function which loads the list of images indicated by an image dataset metadata file as well as the box locations for each image. It makes loading the data necessary to train an object_detector a little more convenient.
`#include <dlib/data_io.h>`
Detailed Documentation
C++ Example Programs: fhog_object_detector_ex.cpp, train_object_detector.cpp
[top]

# load_image_dataset_metadata

dlib comes with a graphical tool for annotating images with labeled rectangles. The tool produces an XML file containing these annotations. Therefore, load_image_dataset_metadata() is a routine for parsing these XML files. Note also that this is the metadata format used by the image labeling tool included with dlib in the tools/imglab folder.
`#include <dlib/data_io.h>`
Detailed Documentation
[top]

# load_libsvm_formatted_data

This is a function that loads the data from a file that uses the LIBSVM format. It loads the data into a std::vector of sparse vectors. If you want to load data into dense vectors (i.e. dlib::matrix objects) then you can use the sparse_to_dense function to perform the conversion. Also, some LIBSVM formatted files number their features beginning with 1 rather than 0. If this bothers you, then you can fix it by using the fix_nonzero_indexing function on the data after it is loaded.
`#include <dlib/data_io.h>`
Detailed Documentation
[top]

# mlp

This object represents a multilayer layer perceptron network that is trained using the back propagation algorithm. The training algorithm also incorporates the momentum method. That is, each round of back propagation training also adds a fraction of the previous update. This fraction is controlled by the momentum term set in the constructor.

It is worth noting that a MLP is, in general, very inferior to modern kernel algorithms such as the support vector machine. So if you haven't tried any other techniques with your data you really should.

`#include <dlib/mlp.h>`
Detailed Documentation
C++ Example Programs: mlp_ex.cpp
Implementations:

> mlp_kernel_1:
> This is implemented in the obvious way.

> kernel_1a | is a typedef for mlp_kernel_1
> kernel_1a_c | is a typedef for kernel_1a that checks its preconditions.

[top]

# modularity

This function computes the modularity of a particular graph clustering. This is a number that tells you how good the clustering is. In particular, it is the measure optimized by the newman_cluster routine.
`#include <dlib/clustering.h>`
Detailed Documentation
[top]

# multiclass_linear_decision_function

This object represents a multiclass classifier built out of a set of binary classifiers. Each binary classifier is used to vote for the correct multiclass label using a one vs. all strategy. Therefore, if you have N classes then there will be N binary classifiers inside this object. Additionally, this object is linear in the sense that each of these binary classifiers is a simple linear plane.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# nearest_center

This function takes a list of cluster centers and a query vector and identifies which cluster center is nearest to the query vector.
`#include <dlib/clustering.h>`
Detailed Documentation
[top]

# newman_cluster

This function performs the clustering algorithm described in the paper

> Modularity and community structure in networks by M. E. J. Newman.

In particular, this is a method for automatically clustering the nodes in a graph into groups. The method is able to automatically determine the number of clusters and does not have any parameters. In general, it is a very good clustering technique.
`#include <dlib/clustering.h>`
Detailed Documentation
[top]

# normalized_function

This object represents a container for another function object and an instance of the vector_normalizer object. It automatically normalizes all inputs before passing them off to the contained function object.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_ex.cpp
[top]

# null_trainer

This is a convenience function for creating null_trainer_type objects.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# null_trainer_type

This object is a simple tool for turning a decision_function (or any object with an interface compatible with decision_function) into a trainer object that always returns the original decision function when you try to train with it.

dlib contains a few "training post processing" algorithms (e.g. reduced and reduced2). These tools take in a trainer object, tell it to perform training, and then they take the output decision function and do some kind of post processing to it. The null_trainer_type object is useful because you can use it to run an already learned decision function through the training post processing algorithms by turning a decision function into a null_trainer_type and then giving it to a post processor.

`#include <dlib/svm.h>`
Detailed Documentation
[top]

# offset_kernel

This object represents a kernel with a fixed value offset added to it.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# one_vs_all_decision_function

This object represents a multiclass classifier built out of a set of binary classifiers. Each binary classifier is used to vote for the correct multiclass label using a one vs. all strategy. Therefore, if you have N classes then there will be N binary classifiers inside this object.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# one_vs_all_trainer

This object is a tool for turning a bunch of binary classifiers into a multiclass classifier. It does this by training the binary classifiers in a one vs. all fashion. That is, if you have N possible classes then it trains N binary classifiers which are then used to vote on the identity of a test sample.
`#include <dlib/svm_threaded.h>`
Detailed Documentation
[top]

# one_vs_one_decision_function

This object represents a multiclass classifier built out of a set of binary classifiers. Each binary classifier is used to vote for the correct multiclass label using a one vs. one strategy. Therefore, if you have N classes then there will be N*(N-1)/2 binary classifiers inside this object.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: multiclass_classification_ex.cpp, custom_trainer_ex.cpp
[top]

# one_vs_one_trainer

This object is a tool for turning a bunch of binary classifiers into a multiclass classifier. It does this by training the binary classifiers in a one vs. one fashion. That is, if you have N possible classes then it trains N*(N-1)/2 binary classifiers which are then used to vote on the identity of a test sample.
`#include <dlib/svm_threaded.h>`
Detailed Documentation
C++ Example Programs: multiclass_classification_ex.cpp, custom_trainer_ex.cpp
[top]

# pick_initial_centers

This is a function that you can use to seed data clustering algorithms like the kkmeans clustering method. What it does is pick reasonable starting points for clustering by basically trying to find a set of points that are all far away from each other.
`#include <dlib/clustering.h>`
Detailed Documentation
C++ Example Programs: kkmeans_ex.cpp
[top]

# polynomial_kernel

This object represents a polynomial kernel for use with kernel learning machines.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# probabilistic

This is a trainer adapter which simply runs the trainer it is given though the train_probabilistic_decision_function function.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# probabilistic_decision_function

This object represents a binary decision function for use with kernel-based learning-machines. It returns an estimate of the probability that a given sample is in the +1 class.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_ex.cpp
[top]

# probabilistic_function

This object represents a binary decision function for use with any kind of binary classifier. It returns an estimate of the probability that a given sample is in the +1 class.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# projection_function

This object represents a function that takes a data sample and projects it into kernel feature space. The result is a real valued column vector that represents a point in a kernel feature space. Instances of this object are created using the empirical_kernel_map.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: linear_manifold_regularizer_ex.cpp
[top]

# radial_basis_kernel

This object represents a radial basis function kernel for use with kernel learning machines.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_ex.cpp
[top]

# randomize_samples

Randomizes the order of samples in a column vector containing sample data.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_ex.cpp
[top]

# ranking_pair

This object is used to contain a ranking example. Therefore, ranking_pair objects are used to represent training examples for learning-to-rank tasks, such as those used by the svm_rank_trainer.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_rank_ex.cpp
Python Example Programs: svm_rank.py
[top]

# rank_features

Finds a ranking of the top N (a user supplied parameter) features in a set of data from a two class classification problem. It does this by computing the distance between the centroids of both classes in kernel defined feature space. Good features are then ones that result in the biggest separation between the two centroids.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: rank_features_ex.cpp
[top]

# rank_unlabeled_training_samples

This routine implements an active learning method for selecting the most informative data sample to label out of a set of unlabeled samples. In particular, it implements the MaxMin Margin and Ratio Margin methods described in the paper:

> Support Vector Machine Active Learning with Applications to Text Classification by Simon Tong and Daphne Koller.

`#include <dlib/svm.h>`
Detailed Documentation
[top]

# rbf_network_trainer

Trains a radial basis function network and outputs a decision_function. This object can be used for either regression or binary classification problems. It's worth pointing out that this object is essentially an unregularized version of kernel ridge regression. This means you should really prefer to use kernel ridge regression instead.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# reduced

This is a convenience function for creating reduced_decision_function_trainer objects.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# reduced2

This is a convenience function for creating reduced_decision_function_trainer2 objects.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_ex.cpp
[top]

# reduced_decision_function_trainer

This is a batch trainer object that is meant to wrap other batch trainer objects that create decision_function objects. It performs post processing on the output decision_function objects with the intent of representing the decision_function with fewer basis vectors.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# reduced_decision_function_trainer2

This is a batch trainer object that is meant to wrap other batch trainer objects that create decision_function objects. It performs post processing on the output decision_function objects with the intent of representing the decision_function with fewer basis vectors.

It begins by performing the same post processing as the reduced_decision_function_trainer object but it also performs a global gradient based optimization to further improve the results. The gradient based optimization is implemented using the approximate_distance_function routine.

`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_ex.cpp
[top]

# rls

This is an implementation of the linear version of the recursive least squares algorithm. It accepts training points incrementally and, at each step, maintains the solution to the following optimization problem:

> find w minimizing: 0.5*dot(w,w) + C*sum_i(y_i - trans(x_i)*w)^2

Where (x_i,y_i) are training pairs. x_i is some vector and y_i is a target scalar value.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# roc_c1_trainer

This is a convenience function for creating roc_trainer_type objects that are setup to pick a point on the ROC curve with respect to the +1 class.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# roc_c2_trainer

This is a convenience function for creating roc_trainer_type objects that are setup to pick a point on the ROC curve with respect to the -1 class.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# roc_trainer_type

This object is a simple trainer post processor that allows you to easily adjust the bias term in a trained decision_function object. That is, this object lets you pick a point on the ROC curve and it will adjust the bias term appropriately.

So for example, suppose you wanted to set the bias term so that the accuracy of your decision function on +1 labeled samples was 99%. To do this you would use an instance of this object declared as follows: `roc_trainer_type<trainer_type>(your_trainer, 0.99, +1);`

`#include <dlib/svm.h>`
Detailed Documentation
[top]

# rr_trainer

Performs linear ridge regression and outputs a decision_function that represents the learned function. In particular, this object can only be used with the linear_kernel. It is optimized for the linear case where the number of features in each sample vector is small (i.e. on the order of 1000 or less since the algorithm is cubic in the number of features.). If you want to use a nonlinear kernel then you should use the krr_trainer.

This object is capable of automatically estimating its regularization parameter using leave-one-out cross-validation.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# rvm_regression_trainer

Trains a relevance vector machine for solving regression problems. Outputs a decision_function that represents the learned regression function.

The implementation of the RVM training algorithm used by this library is based on the following paper:

> Tipping, M. E. and A. C. Faul (2003). Fast marginal likelihood maximisation for sparse Bayesian models. In C. M. Bishop and B. J. Frey (Eds.), Proceedings of the Ninth International Workshop on Artificial Intelligence and Statistics, Key West, FL, Jan 3-6.

`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: rvm_regression_ex.cpp
[top]

# rvm_trainer

Trains a relevance vector machine for solving binary classification problems. Outputs a decision_function that represents the learned classifier.

The implementation of the RVM training algorithm used by this library is based on the following paper:

> Tipping, M. E. and A. C. Faul (2003). Fast marginal likelihood maximisation for sparse Bayesian models. In C. M. Bishop and B. J. Frey (Eds.), Proceedings of the Ninth International Workshop on Artificial Intelligence and Statistics, Key West, FL, Jan 3-6.

`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: rvm_ex.cpp
[top]

# sammon_projection

This is a function object that computes the Sammon projection of a set of N points in a L-dimensional vector space onto a d-dimensional space (d < L), according to the paper:

> A Nonlinear Mapping for Data Structure Analysis (1969) by J.W. Sammon

`#include <dlib/statistics.h>`
Detailed Documentation
[top]

# save_image_dataset_metadata

This routine is a tool for saving labeled image metadata to an XML file. In particular, this routine saves the metadata into a form which can be read by the load_image_dataset_metadata routine. Note also that this is the metadata format used by the image labeling tool included with dlib in the tools/imglab folder.
`#include <dlib/data_io.h>`
Detailed Documentation
[top]

# save_libsvm_formatted_data

This is actually a pair of overloaded functions. Between the two of them they let you save sparse or dense data vectors to file using the LIBSVM format.
`#include <dlib/data_io.h>`
Detailed Documentation
[top]

# select_all_distinct_labels

This is a function which determines all distinct values present in a std::vector and returns the result.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# sequence_labeler

This object is a tool for doing sequence labeling. In particular, it is capable of representing sequence labeling models such as those produced by Hidden Markov SVMs or Conditional Random fields. See the following papers for an introduction to these techniques:

> Hidden Markov Support Vector Machines by Y. Altun, I. Tsochantaridis, T. Hofmann
> Shallow Parsing with Conditional Random Fields by Fei Sha and Fernando Pereira

`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: sequence_labeler_ex.cpp
[top]

# sequence_segmenter

This object is a tool for segmenting a sequence of objects into a set of non-overlapping chunks. An example sequence segmentation task is to take English sentences and identify all the named entities. In this example, you would be using a sequence_segmenter to find all the chunks of contiguous words which refer to proper names.

Internally, the sequence_segmenter uses the BIO (Begin, Inside, Outside) or BILOU (Begin, Inside, Last, Outside, Unit) sequence tagging model. Moreover, it is implemented using a sequence_labeler object and therefore sequence_segmenter objects are examples of chain structured conditional random field style sequence taggers.

`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: sequence_segmenter_ex.cpp
Python Example Programs: sequence_segmenter.py,
[top]

# sigmoid_kernel

This object represents a sigmoid kernel for use with kernel learning machines.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# simplify_linear_decision_function

This is a set of functions that takes various forms of linear decision functions and collapses them down so that they only compute a single dot product when invoked.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# sort_basis_vectors

A kernel based learning method ultimately needs to select a set of basis functions represented by a particular choice of kernel and a set of basis vectors. sort_basis_vectors() is a function which attempts to perform supervised basis set selection. In particular, you give it a candidate set of basis vectors and it sorts them according to how useful they are for solving a particular decision problem.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# sparse_histogram_intersection_kernel

This object represents a histogram intersection kernel kernel for use with kernel learning machines that operate on sparse vectors.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# sparse_linear_kernel

This object represents a linear kernel for use with kernel learning machines that operate on sparse vectors.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# sparse_polynomial_kernel

This object represents a polynomial kernel for use with kernel learning machines that operate on sparse vectors.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# sparse_radial_basis_kernel

This object represents a radial basis function kernel for use with kernel learning machines that operate on sparse vectors.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# sparse_sigmoid_kernel

This object represents a sigmoid kernel for use with kernel learning machines that operate on sparse vectors.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# structural_assignment_trainer

This object is a tool for learning to solve an assignment problem based on a training dataset of example assignments. The training procedure produces an assignment_function object which can be used to predict the assignments of new data. Note that this is just a convenience wrapper around the structural_svm_assignment_problem to make it look similar to all the other trainers in dlib.
`#include <dlib/svm_threaded.h>`
Detailed Documentation
C++ Example Programs: assignment_learning_ex.cpp
[top]

# structural_graph_labeling_trainer

This object is a tool for learning to solve a graph labeling problem based on a training dataset of example labeled graphs. The training procedure produces a graph_labeler object which can be used to predict the labelings of new graphs.

To elaborate, a graph labeling problem is a task to learn a binary classifier which predicts the label of each node in a graph. Additionally, we have information in the form of edges between nodes where edges are present when we believe the linked nodes are likely to have the same label. Therefore, part of a graph labeling problem is to learn to score each edge in terms of how strongly the edge should enforce labeling consistency between its two nodes.

Note that this is just a convenience wrapper around the structural_svm_graph_labeling_problem to make it look similar to all the other trainers in dlib. You might also consider reading the book Structured Prediction and Learning in Computer Vision by Sebastian Nowozin and Christoph H. Lampert since it contains a good introduction to machine learning methods such as the algorithm implemented by the structural_graph_labeling_trainer.

`#include <dlib/svm_threaded.h>`
Detailed Documentation
C++ Example Programs: graph_labeling_ex.cpp
[top]

# structural_object_detection_trainer

This object is a tool for learning to detect objects in images based on a set of labeled images. The training procedure produces an object_detector which can be used to predict the locations of objects in new images.

Note that this is just a convenience wrapper around the structural_svm_object_detection_problem to make it look similar to all the other trainers in dlib.

`#include <dlib/svm_threaded.h>`
Detailed Documentation
C++ Example Programs: fhog_object_detector_ex.cpp, object_detector_ex.cpp, object_detector_advanced_ex.cpp, train_object_detector.cpp
Python Example Programs: train_object_detector.py
[top]

# structural_sequence_labeling_trainer

This object is a tool for learning to do sequence labeling based on a set of training data. The training procedure produces a sequence_labeler object which can be use to predict the labels of new data sequences.

Note that this is just a convenience wrapper around the structural_svm_sequence_labeling_problem to make it look similar to all the other trainers in dlib.

`#include <dlib/svm_threaded.h>`
Detailed Documentation
C++ Example Programs: sequence_labeler_ex.cpp
[top]

# structural_sequence_segmentation_trainer

This object is a tool for learning to do sequence segmentation based on a set of training data. The training procedure produces a sequence_segmenter object which can be used to identify the sub-segments of new data sequences.

This object internally uses the structural_sequence_labeling_trainer to solve the learning problem.

`#include <dlib/svm_threaded.h>`
Detailed Documentation
C++ Example Programs: sequence_segmenter_ex.cpp
Python Example Programs: sequence_segmenter.py,
[top]

# structural_svm_assignment_problem

This object is a tool for learning the parameters needed to use an assignment_function object. It learns the parameters by formulating the problem as a structural SVM problem.
`#include <dlib/svm_threaded.h>`
Detailed Documentation
[top]

# structural_svm_graph_labeling_problem

This object is a tool for learning the weight vectors needed to use a graph_labeler object. It learns the parameter vectors by formulating the problem as a structural SVM problem.
`#include <dlib/svm_threaded.h>`
Detailed Documentation
[top]

# structural_svm_object_detection_problem

This object is a tool for learning the parameter vector needed to use a scan_fhog_pyramid, scan_image_pyramid, scan_image_boxes, or scan_image_custom object.

It learns the parameter vector by formulating the problem as a structural SVM problem. The general approach is similar to the method discussed in Learning to Localize Objects with Structured Output Regression by Matthew B. Blaschko and Christoph H. Lampert. However, the method has been extended to datasets with multiple, potentially overlapping, objects per image and the measure of loss is different from what is described in the paper.

`#include <dlib/svm_threaded.h>`
Detailed Documentation
[top]

# structural_svm_problem

This object, when used with the oca optimizer, is a tool for solving the optimization problem associated with a structural support vector machine. A structural SVM is a supervised machine learning method for learning to predict complex outputs. This is contrasted with a binary classifier which makes only simple yes/no predictions. A structural SVM, on the other hand, can learn to predict complex outputs such as entire parse trees or DNA sequence alignments. To do this, it learns a function F(x,y) which measures how well a particular data sample x matches a label y. When used for prediction, the best label for a new x is given by the y which maximizes F(x,y).
For an introduction to structured support vector machines you should consult the following paper:

> Predicting Structured Objects with Support Vector Machines by Thorsten Joachims, Thomas Hofmann, Yisong Yue, and Chun-nam Yu

For a more detailed discussion of the particular algorithm implemented by this object see the following paper:

> T. Joachims, T. Finley, Chun-Nam Yu, Cutting-Plane Training of Structural SVMs, Machine Learning, 77(1):27-59, 2009.

Note that this object is essentially a tool for solving the 1-Slack structural SVM with margin-rescaling. Specifically, see Algorithm 3 in the above referenced paper.
Finally, for a very detailed introduction to this subject, you should consider the book:

> Structured Prediction and Learning in Computer Vision by Sebastian Nowozin and Christoph H. Lampert

`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_struct_ex.cpp
Python Example Programs: svm_struct.py,
[top]

# structural_svm_problem_threaded

This is just a version of the structural_svm_problem which is capable of using multiple cores/threads at a time. You should use it if you have a multi-core CPU and the separation oracle takes a long time to compute. Or even better, if you have multiple computers then you can use the svm_struct_controller_node to distribute the work across many computers.
`#include <dlib/svm_threaded.h>`
Detailed Documentation
C++ Example Programs: svm_struct_ex.cpp
[top]

# structural_svm_sequence_labeling_problem

This object is a tool for learning the weight vector needed to use a sequence_labeler object. It learns the parameter vector by formulating the problem as a structural SVM problem. The general approach is discussed in the paper:

> Hidden Markov Support Vector Machines by Y. Altun, I. Tsochantaridis, T. Hofmann

While the particular optimization strategy used is the method from:

> T. Joachims, T. Finley, Chun-Nam Yu, Cutting-Plane Training of Structural SVMs, Machine Learning, 77(1):27-59, 2009.

`#include <dlib/svm_threaded.h>`
Detailed Documentation
[top]

# structural_track_association_trainer

This object is a tool for learning to solve a track association problem. That is, it takes in a set of training data and outputs a track_association_function you can use to do detection to track association.
`#include <dlib/svm_threaded.h>`
Detailed Documentation
C++ Example Programs: learning_to_track_ex.cpp
[top]

# svm_c_ekm_trainer

This object represents a tool for training the C formulation of a support vector machine for solving binary classification problems. It is implemented using the empirical_kernel_map to kernelize the svm_c_linear_trainer. This makes it a very fast algorithm capable of learning from very large datasets.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# svm_c_linear_dcd_trainer

This object represents a tool for training the C formulation of a support vector machine to solve binary classification problems. It is optimized for the case where linear kernels are used and is implemented using the method described in the following paper:

> A Dual Coordinate Descent Method for Large-scale Linear SVM by Cho-Jui Hsieh, Kai-Wei Chang, and Chih-Jen Lin

This trainer has the ability to disable the bias term and also to force the last element of the learned weight vector to be 1. Additionally, it can be warm-started from the solution to a previous training run.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: one_class_classifiers_ex.cpp
[top]

# svm_c_linear_trainer

This object represents a tool for training the C formulation of a support vector machine to solve binary classification problems. It is optimized for the case where linear kernels are used and is implemented using the oca optimizer and uses the exact line search described in the following paper:

> Optimized Cutting Plane Algorithm for Large-Scale Risk Minimization by Vojtech Franc, Soren Sonnenburg; Journal of Machine Learning Research, 10(Oct):2157--2192, 2009.

This trainer has the ability to restrict the learned weights to non-negative values.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_sparse_ex.cpp
[top]

# svm_c_trainer

Trains a C support vector machine for solving binary classification problems and outputs a decision_function. It is implemented using the SMO algorithm.

The implementation of the C-SVM training algorithm used by this library is based on the following paper:

- Chih-Chung Chang and Chih-Jen Lin, LIBSVM : a library for support vector machines, 2001. Software available at http://www.csie.ntu.edu.tw/~cjlin/libsvm

`#include <dlib/svm.h>`
Detailed Documentation
[top]

# svm_multiclass_linear_trainer

This object represents a tool for training a multiclass support vector machine. It is optimized for the case where linear kernels are used and implemented using the structural_svm_problem object.
`#include <dlib/svm_threaded.h>`
Detailed Documentation
[top]

# svm_nu_trainer

Trains a nu support vector machine for solving binary classification problems and outputs a decision_function. It is implemented using the SMO algorithm.

The implementation of the nu-svm training algorithm used by this library is based on the following excellent papers:

- Chang and Lin, Training {nu}-Support Vector Classifiers: Theory and Algorithms
- Chih-Chung Chang and Chih-Jen Lin, LIBSVM : a library for support vector machines, 2001. Software available at http://www.csie.ntu.edu.tw/~cjlin/libsvm

`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_ex.cpp, model_selection_ex.cpp
[top]

# svm_one_class_trainer

Trains a one-class support vector classifier and outputs a decision_function. It is implemented using the SMO algorithm.

The implementation of the one-class training algorithm used by this library is based on the following paper:

- Chih-Chung Chang and Chih-Jen Lin, LIBSVM : a library for support vector machines, 2001. Software available at http://www.csie.ntu.edu.tw/~cjlin/libsvm

`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: one_class_classifiers_ex.cpp
[top]

# svm_pegasos

This object implements an online algorithm for training a support vector machine for solving binary classification problems.

The implementation of the Pegasos algorithm used by this object is based on the following excellent paper:

> Pegasos: Primal estimated sub-gradient solver for SVM (2007) by Shai Shalev-Shwartz, Yoram Singer, Nathan Srebro In ICML

This SVM training algorithm has two interesting properties. First, the pegasos algorithm itself converges to the solution in an amount of time unrelated to the size of the training set (in addition to being quite fast to begin with). This makes it an appropriate algorithm for learning from very large datasets. Second, this object uses the kcentroid object to maintain a sparse approximation of the learned decision function. This means that the number of support vectors in the resulting decision function is also unrelated to the size of the dataset (in normal SVM training algorithms, the number of support vectors grows approximately linearly with the size of the training set).

However, if you are considering using svm_pegasos, you should also try the svm_c_linear_trainer for linear kernels or svm_c_ekm_trainer for non-linear kernels since these other trainers are, usually, faster and easier to use than svm_pegasos.

`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_pegasos_ex.cpp, svm_sparse_ex.cpp
[top]

# svm_rank_trainer

This object represents a tool for training a ranking support vector machine using linear kernels. In particular, this object is a tool for training the Ranking SVM described in the paper:

> Optimizing Search Engines using Clickthrough Data by Thorsten Joachims

Finally, note that the implementation of this object is done using the oca optimizer and count_ranking_inversions method. This means that it runs in O(n*log(n)) time, making it suitable for use with large datasets.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_rank_ex.cpp
Python Example Programs: svm_rank.py
[top]

# svm_struct_controller_node

This object is a tool for distributing the work involved in solving a structural_svm_problem across many computers.
`#include <dlib/svm_threaded.h>`
Detailed Documentation
[top]

# svm_struct_processing_node

This object is a tool for distributing the work involved in solving a structural_svm_problem across many computers.
`#include <dlib/svm_threaded.h>`
Detailed Documentation
[top]

# svr_linear_trainer

This object implements a trainer for performing epsilon-insensitive support vector regression. It uses the oca optimizer so it is very efficient at solving this problem when linear kernels are used, making it suitable for use with large datasets.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# svr_trainer

This object implements a trainer for performing epsilon-insensitive support vector regression. It is implemented using the SMO algorithm, allowing the use of non-linear kernels. If you are interested in performing support vector regression with a linear kernel and you have a lot of training data then you should use the svr_linear_trainer which is highly optimized for this case.

The implementation of the eps-SVR training algorithm used by this object is based on the following paper:

- Chih-Chung Chang and Chih-Jen Lin, LIBSVM : a library for support vector machines, 2001. Software available at http://www.csie.ntu.edu.tw/~cjlin/libsvm

`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svr_ex.cpp
[top]

# test_assignment_function

Tests an assignment_function on a set of data and returns the fraction of assignments predicted correctly.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: assignment_learning_ex.cpp
[top]

# test_binary_decision_function

Tests a decision_function that represents a binary decision function and returns the test accuracy.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# test_graph_labeling_function

Tests a graph_labeler on a set of data and returns the fraction of labels predicted correctly.
`#include <dlib/svm_threaded.h>`
Detailed Documentation
[top]

# test_multiclass_decision_function

Tests a multiclass decision function (e.g. one_vs_one_decision_function) and returns a confusion matrix describing the results.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: multiclass_classification_ex.cpp, custom_trainer_ex.cpp
[top]

# test_object_detection_function

Tests an object detector such as the object_detector and returns the precision and recall.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: fhog_object_detector_ex.cpp, object_detector_ex.cpp, object_detector_advanced_ex.cpp, train_object_detector.cpp
[top]

# test_ranking_function

Tests a decision_function's ability to correctly rank a dataset and returns the resulting ranking accuracy and mean average precision metrics.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_rank_ex.cpp
Python Example Programs: svm_rank.py
[top]

# test_regression_function

Tests a regression function (e.g. decision_function) and returns the mean squared error and R-squared value.
`#include <dlib/svm.h>`
Detailed Documentation
[top]

# test_sequence_labeler

Tests a sequence_labeler on a set of data and returns a confusion matrix describing the results.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: sequence_labeler_ex.cpp
[top]

# test_sequence_segmenter

Tests a sequence_segmenter on a set of data and returns the resulting precision, recall, and F1-score.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: sequence_segmenter_ex.cpp
Python Example Programs: sequence_segmenter.py,
[top]

# test_track_association_function

Tests a track_association_function on a set of data and returns the fraction of detections which were correctly associated to their tracks.
`#include <dlib/svm_threaded.h>`
Detailed Documentation
C++ Example Programs: learning_to_track_ex.cpp
[top]

# track_association_function

This object is a tool that helps you implement an object tracker. So for example, if you wanted to track people moving around in a video then this object can help. In particular, imagine you have a tool for detecting the positions of each person in an image. Then you can run this person detector on the video and at each time step, i.e. at each frame, you get a set of person detections. However, that by itself doesn't tell you how many people there are in the video and where they are moving to and from. To get that information you need to figure out which detections match each other from frame to frame. This is where the track_association_function comes in. It performs the detection to track association. It will also do some of the track management tasks like creating a new track when a detection doesn't match any of the existing tracks.

Internally, this object is implemented using the assignment_function object. In fact, it's really just a thin wrapper around assignment_function and exists just to provide a more convenient interface to users doing detection to track association.

`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: learning_to_track_ex.cpp
[top]

# train_probabilistic_decision_function

Trains a probabilistic_function using some sort of binary classification trainer object such as the svm_nu_trainer or krr_trainer.

The probability model is created by using the technique described in the following papers:

> Probabilistic Outputs for Support Vector Machines and Comparisons to Regularized Likelihood Methods by John C. Platt. March 26, 1999

> A Note on Platt's Probabilistic Outputs for Support Vector Machines by Hsuan-Tien Lin, Chih-Jen Lin, and Ruby C. Weng

`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_ex.cpp
[top]

# vector_normalizer

This object represents something that can learn to normalize a set of column vectors. In particular, normalized column vectors should have zero mean and a variance of one.
`#include <dlib/statistics.h>`
Detailed Documentation
C++ Example Programs: svm_ex.cpp
[top]

# vector_normalizer_frobmetric

This object is a tool for performing the FrobMetric distance metric learning algorithm described in the following paper:

> A Scalable Dual Approach to Semidefinite Metric Learning By Chunhua Shen, Junae Kim, Lei Wang, in CVPR 2011

Therefore, this object is a tool that takes as input training triplets (anchor, near, far) of vectors and attempts to learn a linear transformation T such that:

> `length(T*anchor-T*near) + 1 < length(T*anchor - T*far)`

That is, you give a bunch of anchor vectors and for each anchor vector you specify some vectors which should be near to it and some that should be far form it. This object then tries to find a transformation matrix that makes the "near" vectors close to their anchors while the "far" vectors are farther away.
`#include <dlib/statistics.h>`
Detailed Documentation
[top]

# vector_normalizer_pca

This object represents something that can learn to normalize a set of column vectors. In particular, normalized column vectors should have zero mean and a variance of one. This object also uses principal component analysis for the purposes of reducing the number of elements in a vector.
`#include <dlib/statistics.h>`
Detailed Documentation
[top]

# verbose_batch

This is a convenience function for creating batch_trainer objects. This function generates a batch_trainer that will print status messages to standard output so that you can observe the progress of a training algorithm.
`#include <dlib/svm.h>`
Detailed Documentation
C++ Example Programs: svm_pegasos_ex.cpp
[top]

# verbose_batch_cached

This is a convenience function for creating batch_trainer objects. This function generates a batch_trainer that will print status messages to standard output so that you can observe the progress of a training algorithm. It will also be configured to use a kernel matrix cache.
`#include <dlib/svm.h>`
Detailed Documentation