Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Redefine maxit in UnivariateSpline

I tried to use SciPy's smoothing univariate spline

from scipy.interpolate import UnivariateSpline
spl = UnivariateSpline(x, y)

And I get this error message.

/usr/lib/python3.5/site-packages/scipy/interpolate/fitpack2.py:222: UserWarning: The maximal number of iterations maxit (set to 20 by the program) allowed for finding a smoothing spline with fp=s has been reached: s too small. There is an approximation returned but the corresponding weighted sum of squared residuals does not satisfy the condition abs(fp-s)/s < tol. warnings.warn(message)

How can I redefine the maxit parameter? I haven't been able to find anything in the SciPy manual except that it's a keyword in class scipy.odr.ODR. I haven't had much luck though.

like image 749
shadeless Avatar asked Jul 18 '26 00:07

shadeless


1 Answers

You cannot change this parameter, it's fixed deep down in the FITPACK code:

https://github.com/scipy/scipy/blob/master/scipy/interpolate/fitpack/curfit.f#L220

In principle, you could modify the Fortran sources and recompile scipy, but this is almost surely not what you want to do. Instead, you could use the s parameter of the UnivariateSpline (or splrep, for that matter) to see if you're getting something useful given your data x and y.

And, by the way, ODR has nothing to do with this.

like image 147
ev-br Avatar answered Jul 21 '26 00:07

ev-br



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!