pystruct.learners.LatentSSVM

class pystruct.learners.LatentSSVM(base_ssvm, latent_iter=5, logger=None)

Stuctured SVM solver for latent-variable models.

Alternates between doing latent variale completion and solving the completed SSVM problem using the base_ssvm solver.

The model is expected to know how to initialize itself - it should provide a init_latent procedure.

If the base_ssvm is an n-slack SSVM, the current constraints will be adjusted after recomputing the latent variables H. If the base_ssvm is a 1-slack SSVM, the inference cache will be reused. Both methods drastically speed up learning.

Parameters :

base_ssvm : object

SSVM solver instance for solving the completed problem.

latent_iter : int (default=5)

Number of iterations in the completion / refit loop.

logger : object

Logger instance.

Attributes

w

Methods

fit(X, Y[, H_init])
get_params([deep]) Get parameters for the estimator
predict(X)
predict_latent(X)
score(X, Y) Compute score as 1 - loss over whole data set.
set_params(**params) Set the parameters of the estimator.
__init__(base_ssvm, latent_iter=5, logger=None)
get_params(deep=True)

Get parameters for the estimator

Parameters :

deep: boolean, optional :

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns :

params : mapping of string to any

Parameter names mapped to their values.

score(X, Y)

Compute score as 1 - loss over whole data set.

Returns the average accuracy (in terms of model.loss) over X and Y.

Parameters :

X : iterable

Evaluation data.

Y : iterable

True labels.

Returns :

score : float

Average of 1 - loss over training examples.

set_params(**params)

Set the parameters of the estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The former have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Returns :self :