@@ -358,9 +358,13 @@ def line_search(self, X, y, sample_weight):
358358 warnings .warn (
359359 f"Line search of Newton solver { self .__class__ .__name__ } at iteration "
360360 f"#{ self .iteration } did no converge after 21 line search refinement "
361- "iterations." ,
361+ "iterations. It will now resort to lbfgs instead. " ,
362362 ConvergenceWarning ,
363363 )
364+ if self .verbose :
365+ print (" Lines search did not converge and resorts to lbfgs instead." )
366+ self .use_fallback_lbfgs_solve = True
367+ return
364368
365369 self .raw_prediction = raw
366370
@@ -467,6 +471,8 @@ def solve(self, X, y, sample_weight):
467471 # self.loss_value, self.gradient_old, self.gradient,
468472 # self.raw_prediction.
469473 self .line_search (X = X , y = y , sample_weight = sample_weight )
474+ if self .use_fallback_lbfgs_solve :
475+ break
470476
471477 # 4. Check convergence
472478 # Sets self.converged.
@@ -537,7 +543,7 @@ def inner_solve(self, X, y, sample_weight):
537543 except (np .linalg .LinAlgError , scipy .linalg .LinAlgWarning ) as e :
538544 warnings .warn (
539545 f"The inner solver of { self .__class__ .__name__ } stumbled upon a "
540- "singular or very ill-conditioned hessian matrix at iteration "
546+ "singular or very ill-conditioned Hessian matrix at iteration "
541547 f"#{ self .iteration } . It will now resort to lbfgs instead.\n "
542548 "Further options are to use another solver or to avoid such situation "
543549 "in the first place. Possible remedies are removing collinearfeatures "
0 commit comments