File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -208,8 +208,20 @@ def _run_interface(self, runtime):
208208 )
209209
210210 # Fit the model
211- model = lm .Ridge (alpha = self .inputs .ridge_alpha , fit_intercept = False )
212- model .fit (colmat [mask .reshape (- 1 ), :], data [mask ])
211+ model = lm .Ridge (alpha = self .inputs .ridge_alpha , fit_intercept = False , solver = 'lsqr' )
212+ for attempt in range (3 ):
213+ model .fit (colmat [mask .reshape (- 1 ), :], data [mask ])
214+ extreme = np .abs (model .coef_ ).max ()
215+ LOGGER .debug (f"Model fit attempt { attempt } : max(|coeffs|) = { extreme } " )
216+ # Normal values seem to be ~1e2, bad ~1e8. May want to tweak this if
217+ # these distributions are wider than I think.
218+ if extreme < 1e4 :
219+ break
220+ else :
221+ raise RuntimeError (
222+ f"Spline fit of input file { self .inputs .in_data } failed. "
223+ f"Extreme value { extreme :.2e} detected in spline coefficients."
224+ )
213225
214226 # Store coefficients
215227 index = 0
You can’t perform that action at this time.
0 commit comments