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.SubgradientLatentSSVM(model[, ...]) Latent Variable Structured SVM solver using subgradient descent.
learners.PrimalDSStructuredSVM(model[, ...]) Uses downhill simplex for optimizing an unconstraint primal.
learners.FrankWolfeSSVM(model[, max_iter, ...]) Structured SVM solver using Block-coordinate Frank-Wolfe.

Models

This module contains model formulations for several settings. They provide the glue between the learning algorithm and the data (and inference).

There are two main classes of models, conditional random field models (CRFs) and classification models (Clfs).

The BinaryClf implements a standard binary classifier, the MultiClassClf a linear multi-class classifier. Together with a max-margin learner, these produce standard binary SVMs and Crammer-Singer multi-class SVMs. MultiLabelClf implements a multi label model with different possible pairwise interactions.

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.

Classifiers

models.BinaryClf([n_features]) Formulate standard linear binary SVM in CRF framework.
models.MultiClassClf([n_features, ...]) Formulate linear multiclass SVM in C-S style in CRF framework.
models.MultiLabelClf([n_labels, n_features, ...]) Multi-label model for predicting several binary classes.

Conditional Random Fields

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.ChainCRF([n_states, n_features, ...]) Linear-chain CRF.
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(...[, ...]) Computes the maximizing assignment of a pairwise discrete energy function.
inference.inference_qpbo(unary_potentials, ...) Inference with PyQPBO backend.
inference.inference_lp(unary_potentials, ...) Inference with build-in LP solver using cvxopt backend.
inference.inference_ad3(unary_potentials, ...) Inference with AD3 dual decomposition subgradient solver.
inference.inference_ogm(unary_potentials, ...) Inference with OpenGM backend.

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.