stroll : Structured Output Learning Library
stroll (STRuctured Output Learning Library) is a library for Structured Output Learning. For now it only supports various training and prediction approaches for Conditional Random Fields (CRF), but support for Structural SVMs is planned for the near future. stroll is based on libDAI.
The software is released as open source software under the GNU GPL v3 license.
Features
- Supports general (possibly intractable) factor graphs.
- Easy to use. We provide Python bindings for stroll that simplify the development with stroll considerably.
- Most of the inference algorithms implemented by libDAI can be used with smaller modifications for both, training and prediction with CRFs.
- Implements the spanning tree based training approach for CRFs described in our AISTATS paper
Releases
- stroll-0.1.tar.gz (Release date: 2009/03/31).
Warning
stroll is still in alpha testing. Various algorithms might be broken and we also do not guarantee a stable API.
Usage
See the AISTATS project page for full examples, the example here is slightly simplified, but should demonstrate the usage of the Python bindings of stroll.
import stroll
import dai
import helpers
import scipy.io
import numpy
#----------------------------------------------------------------------------
# read the data set
#----------------------------------------------------------------------------
filename_train = 'scene_train.mat'
D = scipy.io.loadmat(filename_train)
train_data = numpy.mat(D['dataTrain'])
train_label = numpy.mat(D['labelTrain'])
n_labels = train_label.shape[1]
train = helpers.constructMultilabelDataset(train_data, n_labels, train_label)
#----------------------------------------------------------------------------
# perform the training and prediction (on training data)
#----------------------------------------------------------------------------
# training settings
lambda_l1 = 0
lambda_l2 = 1
n_trees = 1
average = 1
# train the model
crf = stroll.CRFTrainSpanning(train, lambda_l1 , lambda_l2, n_trees, average)
crf.init()
crf.train()
# get the parameters
model = crf.parameters()
model = crf.reweightParameters()
predictor = stroll.Predict(model)
# predict on training data
result = predictor.MAP(train)
P = helpers.Prediction2Label(result, n_labels)
err = helpers.computeError(train_label, P)
print("training error: " + str(err))