Learning

This module contains algorithms for solving the structured learning model. Most are based on structured support vector machines.

Currently, I advise to use the OneSlackSSVM, which solves the QP using CVXOPT. SubgradientSSVM is a very simple implementation, that also might be interesting.

NSlackSSVM is the n-slack formulation of the QP and should work reliably, but is not as optimized as OneSlackSSVM. The rest is experimental / for testing.

learners.OneSlackSSVM(model[, max_iter, C, ...]) Structured SVM solver for the 1-slack QP with l1 slack penalty.
learners.NSlackSSVM(model[, max_iter, C, ...]) Structured SVM solver for the n-slack QP with l1 slack penalty.
learners.SubgradientSSVM(model[, max_iter, ...]) Structured SVM solver using subgradient descent.
learners.StructuredPerceptron(model[, ...]) Structured Perceptron training.
learners.LatentSSVM(base_ssvm[, ...]) Stuctured SVM solver for latent-variable models.
learners.LatentSubgradientSSVM(model[, ...]) Latent Variable Structured SVM solver using subgradient descent.
learners.PrimalDSStructuredSVM(model[, ...]) Uses downhill simplex for optimizing an unconstraint primal.

Models

This module contains model formulations for several settings. They provide the glue between the learning algorithm and the data (and inference). The BinarySVMModel implements a standard SVM, the CrammerSingerSVMModel a multi-class SVM - which is surprisingly efficient and sometimes comparable to LibLinear Crammer-Singer Implementation.

GraphCRF implements a simple pairwise model for arbitrary graphs, while EdgeFeatureGraphCRF allows for arbitrary features for each edge, symmetric, assymmetric and arbitrary potentials.

GridCRF is a convenience class for grid graphs.

models.BinarySVMModel(n_features) Formulate standard linear binary SVM in CRF framework.
models.CrammerSingerSVMModel(n_features[, ...]) Formulate linear multiclass SVM in C-S style in CRF framework.
models.GraphCRF([n_states, n_features, ...]) Pairwise CRF on a general graph.
models.EdgeFeatureGraphCRF([n_states, ...]) Pairwise CRF with features/strength associated to each edge.
models.LatentGraphCRF(n_labels[, ...]) CRF with latent states for variables.
models.LatentNodeCRF([n_labels, n_features, ...]) CRF with latent variables.
models.GridCRF([n_states, n_features, ...]) Pairwise CRF on a 2d grid.
models.DirectionalGridCRF([n_states, ...]) CRF in which each direction of edges has their own set of parameters.

Inference

inference.inference_dispatch(...[, relaxed, ...]) Wrapper function to dispatch between inference method by string.
inference.inference_qpbo(unary_potentials, ...) Inference with PyQPBO backend.
inference.inference_dai(unary_potentials, ...) Inference with LibDAI backend.
inference.inference_lp(unary_potentials, ...) Inference with build-in LP solver using GLPK backend.
inference.inference_ad3(unary_potentials, ...) Inference with AD3 dual decomposition subgradient solver.

Utilities

utils.SaveLogger(file_name[, save_every, ...]) Logging class that stores the model periodically.

plot_learning

This module provides a callable for easy evaluation of stored models.

plot_learning.plot_learning(ssvm[, time]) Plot optimization curves and cache hits.