Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error LinAlgError: SVD did not converge in Linear Least Squares #2

Closed
abearab opened this issue Aug 6, 2022 · 2 comments
Closed

Error LinAlgError: SVD did not converge in Linear Least Squares #2

abearab opened this issue Aug 6, 2022 · 2 comments

Comments

@abearab
Copy link

abearab commented Aug 6, 2022

When I try running blitz.gsea function in jupyter for multiple tests in a for loop, I get this error message.

LinAlgError: SVD did not converge in Linear Least Squares

full message

python3.7/site-packages/blitzgsea/__init__.py in gsea(signature, library, permutations, anchors, min_size, max_size, processes, plotting, verbose, symmetric, signature_cache, seed)
    239         f_alpha_pos, f_beta_pos, f_pos_ratio, ks_pos, ks_neg = blitzgsea_signature_anchors[sig_hash]
    240     else:
--> 241         f_alpha_pos, f_beta_pos, f_pos_ratio, ks_pos, ks_neg = estimate_parameters(signature, abs_signature, signature_map, library, permutations=permutations, calibration_anchors=anchors, processes=processes, symmetric=symmetric, plotting=plotting, verbose=verbose, seed=seed)
    242         blitzgsea_signature_anchors[sig_hash] = (f_alpha_pos, f_beta_pos, f_pos_ratio, ks_pos, ks_neg)
    243 

python3.7/site-packages/blitzgsea/__init__.py in estimate_parameters(signature, abs_signature, signature_map, library, permutations, symmetric, calibration_anchors, plotting, processes, verbose, seed)
    120 
    121     f_alpha_pos = loess_interpolation(x, alpha_pos)
--> 122     f_beta_pos = loess_interpolation(x, beta_pos, frac=0.2)
    123 
    124     f_alpha_neg = loess_interpolation(x, alpha_neg)

python3.7/site-packages/blitzgsea/__init__.py in loess_interpolation(x, y, frac)
     76 def loess_interpolation(x, y, frac=0.5):
     77     yl = np.array(y)
---> 78     xout, yout, wout = loess_1d(x, yl, frac=frac)
     79     return interpolate.interp1d(xout, yout)
     80 

python3.7/site-packages/loess/loess_1d.py in loess_1d(x, y, xnew, degree, frac, npoints, rotate, sigy)
    274             biweights = (1 - uu)**2
    275             tot_weights = dist_weights*biweights
--> 276             poly = polyfit1d(x[w], y[w], degree, tot_weights)
    277             yfit = poly.yfit
    278             badOld = bad

python3.7/site-packages/loess/loess_1d.py in __init__(self, x, y, degree, weights)
     81         a = x[:, None]**np.arange(degree + 1)
     82         self.degree = degree
---> 83         self.coeff = np.linalg.lstsq(a*sqw[:, None], y*sqw, rcond=None)[0]
     84         self.yfit = a @ self.coeff
     85 

<__array_function__ internals> in lstsq(*args, **kwargs)

python3.7/site-packages/numpy/linalg/linalg.py in lstsq(a, b, rcond)
   2304         # lapack can't handle n_rhs = 0 - so allocate the array one larger in that axis
   2305         b = zeros(b.shape[:-2] + (m, n_rhs + 1), dtype=b.dtype)
-> 2306     x, resids, rank, s = gufunc(a, b, rcond, signature=signature, extobj=extobj)
   2307     if m == 0:
   2308         x[...] = 0

python3.7/site-packages/numpy/linalg/linalg.py in _raise_linalgerror_lstsq(err, flag)
     98 
     99 def _raise_linalgerror_lstsq(err, flag):
--> 100     raise LinAlgError("SVD did not converge in Linear Least Squares")
    101 
    102 def get_linalg_error_extobj(callback):

@abearab
Copy link
Author

abearab commented Aug 6, 2022

it seems more like a @numpy / @scipy issue – jaakkopasanen/AutoEq#256

I had:

scipy.__version__
'1.7.3'
np.__version__
'1.19.1'

@abearab abearab changed the title Error Error LinAlgError: SVD did not converge in Linear Least Squares Aug 6, 2022
@abearab
Copy link
Author

abearab commented Aug 8, 2022

Okay! I need to avoid small sets in the library input for running gsea function.

@abearab abearab closed this as completed Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant