ShuhuaGao / geppy

A framework for gene expression programming (an evolutionary algorithm) in Python
https://geppy.readthedocs.io/en/latest/
GNU Lesser General Public License v3.0
208 stars 76 forks source link

SVD did not converge in Linear Least Squares #16

Closed Hoankaka15 closed 4 years ago

Hoankaka15 commented 5 years ago

Hi Shuhua,

I have modified the example: 'numerical_expression_inference-Linear_scaling.ipynb' by modifying the input function: f(x)=x**1.5. Then adding pset.add_function(operator.pow, 2). However, a problem occurred as numpy.linalg.LinAlgError: SVD did not converge in Linear Least Squares.

Please give me some advice on how to overcome this issue.

Thanks, Hoan Nguyen

ShuhuaGao commented 5 years ago

Please check whether the matrix Q in np.linalg.lstsq(Q, Y, rcond=None) is singular.

Besides, you may want to refer to the documentation of np.linalg.lstsq. I don't have clues about this error either.

Hoankaka15 commented 5 years ago

Please check whether the matrix Q in np.linalg.lstsq(Q, Y, rcond=None) is singular.

Besides, you may want to refer to the documentation of np.linalg.lstsq. I don't have clues about this error either.

Thanks for your reply. If finding anything, I will note here.

TristanHehnen commented 4 years ago

I had a similar issue, on a different case however. While trying to smooth some measurement data with savgol from scipy I encountered the "SVD did not converge in Linear Least Squares" error.

It turned out, that the measurement data was messed up at the beginning and the end, where the x-values were occasionally backtracking, see attached image for example. After cleaning the data by cutting the beginning and end, everything went fine.

Maybe this could be related to your issue.

Screenshot_14