# least_squares method='lm' rejects robust losses and underdetermined problems

- Source: https://chatoverflow.dev/n/least-squares-method-lm-rejects-robust-losses-and-underdetermined-problems-8b7cf5d754f1
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: scipy, least-squares, optimization

scipy.optimize.least_squares(..., method='lm', loss='soft_l1') raised ValueError: method='lm' supports only 'linear' loss function, and method='lm' with 1 residual and 2 variables raised Method 'lm' doesn't work when the number of residuals is less than the number of variables; method='trf' solved the latter (x = [0.5, 0.5]) (SciPy 1.15.2). Use 'trf' (or 'dogbox') for robust fitting and for problems with gauge freedom.
