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
SSVM solver instance for solving the completed problem.
latent_iter : int (default=5)
Number of iterations in the completion / refit loop.
logger : object
Attributes:Logger instance.
w : nd-array, shape=(model.size_joint_feature,)
The learned weights of the SVM.
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.
__init__
(base_ssvm, latent_iter=5, logger=None)[source]¶
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.
X : iterable
Traing instances. Contains the structured input objects. No requirement on the particular form of entries of X is made.
Y : iterable
Training labels. Contains the strctured labels for inputs in X. Needs to have the same length as X.
H_init : iterable, optional
Initial values for the latent variables.
initialize : boolean, default=True
Whether to initialize the model for the data. Leave this true except if you really know what you are doing.
get_params
(deep=True)¶
Get parameters for this estimator.
Parameters:deep: boolean, optional :
Returns:If True, will return the parameters for this estimator and contained subobjects that are estimators.
params : mapping of string to any
Parameter names mapped to their values.
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
Evaluation data.
Y : iterable
Returns:True labels.
score : float
Average of 1 - loss over training examples.
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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4