pystruct.learners.LatentSSVM(base_ssvm, latent_iter=5, logger=None)[source]¶Stuctured SVM solver for latent-variable models.
This is a hard-EM-style algorithm that alternates between
latent variable completion for the ground truth and
learning the parameters with the latent variables held fixed
using the base_ssvm solver.
The model is expected to know how to initialize itself
- it should provide a init_latent procedure. Optionally the H_init
parameter can be passed to fit, to explicitly initialize the latent
variables in the first iteration.
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.
If base_ssvm is an 1-slack SSVM, this corresponds to the approach of Yu and Joachims, Learning Structural SVMs with Latent Variables.
| Parameters: | base_ssvm : object
latent_iter : int (default=5)
logger : object
|
|---|---|
| Attributes: | w : nd-array, shape=(model.size_joint_feature,)
|
Methods
fit(X, Y[, H_init, initialize]) |
Learn parameters using the concave-convex procedure. |
get_params([deep]) |
Get parameters for this 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 this estimator. |
fit(X, Y, H_init=None, initialize=True)[source]¶Learn parameters using the concave-convex procedure.
If no H_init is given, the latent variables are initialized
using the init_latent method of the model.
| Parameters: | X : iterable
Y : iterable
H_init : iterable, optional
initialize : boolean, default=True
|
|---|
get_params(deep=True)¶Get parameters for this estimator.
| Parameters: | deep: boolean, optional :
|
|---|---|
| Returns: | params : mapping of string to any
|
score(X, Y)[source]¶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
Y : iterable
|
|---|---|
| Returns: | score : float
|
set_params(**params)¶Set the parameters of this 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 : |
|---|