PAMIR

class cbar.pamir.PAMIR(max_iter=100000, C=1.0, valid_interval=10000, max_dips=20, verbose=True)

Passive Agressive Model for Image Retrieval

Parameters:
  • max_iter (int) – The maximum number of iterations.
  • C (float) – The regularization constant.
  • valid_interval (int) – The interval at which a validation of the current model state is performed.
  • max_dips (int) – The maximum number of dips the algorithm is allowed to suffer.
W

array, shape = [n_classes, n_features] – The parameter matrix.

References

[1]Grangier, D. and Bengio, S., 2008. A discriminative kernel-based approach to rank images from text queries. IEEE transactions on pattern analysis and machine intelligence, 30(8), pp.1371-1384.
[2]Chechik, G., Ie, E., Rehn, M., Bengio, S. and Lyon, D., 2008, October. Large-scale content-based audio retrieval from text queries. In Proceedings of the 1st ACM international conference on Multimedia information retrieval (pp. 105-112). ACM.

Examples

TBD

>>> clf = PAMIR()
>>> clf.fit(...)
_init_W(n, m)

Initialize the parameter matrix \(W \in \mathbb{R}^{n imes m}\)

Parameters:
  • n (int) – First dimension for W. Number of classes.
  • m (int) – Second dimension for W. Number of features.
fit(X, Y, Q, X_val=None, Y_val=None, weights=None)

Fit the model.

Parameters:
  • X (array-like, shape = [n_samples, n_features]) – Training data
  • Y (array-like, shape = [n_samples, n_classes]) – Training labels
  • Q (array-like, shape = [n_queries, n_classes]) – Training queries
  • X_val (array-like, shape = [n_samples, n_features], optional) – Validation data
  • Y_val (array-like, shape = [n_samples, n_classes], optional) – Validation labels
  • weights (array-like, shape = [n_queries], optional) – Query weights
Returns:

self – The fitted model.

Return type:

PAMIR instance

fit_partial(X, Y, Q, X_val=None, Y_val=None, weights=None)

Fit the model. Repeated calls to this method will cause training to resume from the current model state.

Parameters:
  • X (array-like, shape = [n_samples, n_features]) – Training data
  • Y (array-like, shape = [n_samples, n_classes]) – Training labels
  • Q (array-like, shape = [n_queries, n_classes]) – Training queries
  • X_val (array-like, shape = [n_samples, n_features], optional) – Validation data
  • Y_val (array-like, shape = [n_samples, n_classes], optional) – Validation labels
  • weights (array-like, shape = [n_queries], optional) – Query weights
Returns:

self – The fitted model.

Return type:

PAMIR instance

predict(Q, X_test)
Parameters:
  • X (array-like, shape = [n_samples, n_features]) – Training data
  • Y (array-like, shape = [n_samples, n_classes]) – Training labels
Returns:

self – This model

Return type:

object