Orthogonal Matching Pursuit (OMP).
Solves n_targets Orthogonal Matching Pursuit problems. An instance of the problem has the form:
When parametrized by the number of non-zero coefficients using n_nonzero_coefs: argmin ||y - Xgamma||^2 subject to ||gamma||_0 <= n_{nonzero coefs}
When parametrized by error using the parameter tol: argmin ||gamma||_0 subject to ||y - Xgamma||^2 <= tol
Read more in the User Guide.
Input data. Columns are assumed to have unit norm.
Input targets.
Desired number of non-zero entries in the solution. If None (by default) this value is set to 10% of n_features.
Maximum squared norm of the residual. If not None, overrides n_nonzero_coefs.
Whether to perform precomputations. Improves performance when n_targets or n_samples is very large.
Whether the design matrix X must be copied by the algorithm. A false value is only helpful if X is already Fortran-ordered, otherwise a copy is made anyway.
Whether to return every value of the nonzero coefficients along the forward path. Useful for cross-validation.
Whether or not to return the number of iterations.
Coefficients of the OMP solution. If return_path=True, this contains the whole coefficient path. In this case its shape is (n_features, n_features) or (n_features, n_targets, n_features) and iterating over the last axis generates coefficients in increasing order of active features.
Number of active features across every target. Returned only if return_n_iter is set to True.
See also
OrthogonalMatchingPursuitOrthogonal Matching Pursuit model.
orthogonal_mp_gramSolve OMP problems using Gram matrix and the product X.T * y.
lars_pathCompute Least Angle Regression or Lasso path using LARS algorithm.
sklearn.decomposition.sparse_encodeSparse coding.
Orthogonal matching pursuit was introduced in S. Mallat, Z. Zhang, Matching pursuits with time-frequency dictionaries, IEEE Transactions on Signal Processing, Vol. 41, No. 12. (December 1993), pp. 3397-3415. (https://www.di.ens.fr/~mallat/papiers/MallatPursuit93.pdf)
This implementation is based on Rubinstein, R., Zibulevsky, M. and Elad, M., Efficient Implementation of the K-SVD Algorithm using Batch Orthogonal Matching Pursuit Technical Report - CS Technion, April 2008. https://www.cs.technion.ac.il/~ronrubin/Publications/KSVD-OMP-v2.pdf
>>> from sklearn.datasets import make_regression >>> from sklearn.linear_model import orthogonal_mp >>> X, y = make_regression(noise=4, random_state=0) >>> coef = orthogonal_mp(X, y) >>> coef.shape (100,) >>> X[:1,] @ coef array([-78.68...])
© 2007–2025 The scikit-learn developers
Licensed under the 3-clause BSD License.
https://scikit-learn.org/1.6/modules/generated/sklearn.linear_model.orthogonal_mp.html