pystruct.models.
MultiLabelClf
(n_labels=None, n_features=None, edges=None, inference_method=None)[source]¶Multi-label model for predicting several binary classes.
Multi-label classification is a generalization of multi-class classification, in that multiple classes can be present in each example. This can also be thought of as predicting binary indicator per class.
This class supports different models via the “edges” parameter. Giving no edges yields independent classifiers for each class. Giving “full” yields a fully connected graph over the labels, while “tree” yields the best tree-shaped graph (using the Chow-Liu algorithm). It is also possible to specify a custom connectivity structure.
Parameters: | n_labels : int (default=None)
n_features : int (default=None)
edges : array-like, string or None
inference_method : :
|
---|
Methods
batch_inference (X, w[, relaxed]) |
|
batch_joint_feature (X, Y[, Y_true]) |
|
batch_loss (Y, Y_hat) |
|
batch_loss_augmented_inference (X, Y, w[, ...]) |
|
continuous_loss (y, y_hat) |
|
inference (x, w[, relaxed, return_energy]) |
Inference for x using parameters w. |
initialize (X, Y) |
|
joint_feature (x, y) |
|
loss (y, y_hat) |
|
loss_augmented_inference (x, y, w[, relaxed, ...]) |
Loss-augmented Inference for x relative to y using parameters w. |
max_loss (y) |
inference
(x, w, relaxed=False, return_energy=False)¶Inference for x using parameters w.
Finds (approximately) armin_y np.dot(w, joint_feature(x, y)) using self.inference_method.
Parameters: | x : tuple
w : ndarray, shape=(size_joint_feature,)
relaxed : bool, default=False
return_energy : bool, default=False
|
---|---|
Returns: | y_pred : ndarray or tuple
|
loss_augmented_inference
(x, y, w, relaxed=False, return_energy=False)¶Loss-augmented Inference for x relative to y using parameters w.
Finds (approximately) armin_y_hat np.dot(w, joint_feature(x, y_hat)) + loss(y, y_hat) using self.inference_method.
Parameters: | x : tuple
y : ndarray, shape (n_nodes,)
w : ndarray, shape=(size_joint_feature,)
relaxed : bool, default=False
return_energy : bool, default=False
|
---|---|
Returns: | y_pred : ndarray or tuple
|