pystruct.learners.StructuredPerceptron(model, max_iter=100, verbose=0, batch=False, decay_exponent=0, decay_t0=10, average=False, n_jobs=1, logger=None)[source]¶Structured Perceptron training.
Implements a simple structured perceptron with optional averaging. The structured perceptron approximately minimizes the zero-one loss, therefore the learning does not take
model.lossinto account. It is just shown to illustrate the learning progress.As the perceptron learning is not margin-based, the model does not need to provide loss_augmented_inference.
| Parameters: | model : StructuredModel
|
|---|---|
| Attributes: | w : nd-array, shape=(model.size_joint_feature,)
``loss_curve_`` : list of float
|
Methods
fit(X, Y[, initialize]) |
Learn parameters using structured perceptron. |
get_params([deep]) |
Get parameters for this estimator. |
predict(X) |
Predict output on examples in X. |
score(X, Y) |
Compute score as 1 - loss over whole data set. |
set_params(**params) |
Set the parameters of this estimator. |
__init__(model, max_iter=100, verbose=0, batch=False, decay_exponent=0, decay_t0=10, average=False, n_jobs=1, logger=None)[source]¶fit(X, Y, initialize=True)[source]¶Learn parameters using structured perceptron.
| Parameters: | X : iterable
Y : iterable
initialize : boolean, default=True
|
|---|
get_params(deep=True)¶Get parameters for this estimator.
| Parameters: | deep: boolean, optional :
|
|---|---|
| Returns: | params : mapping of string to any
|
predict(X)¶Predict output on examples in X.
| Parameters: | X : iterable
|
|---|---|
| Returns: | Y_pred : list
|
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
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 : |
|---|