Iteration limit handling and ConvergenceWarning in scikit-learn iterative estimators
0 reputation · 06 Aug 2020, 21:41 UTC
Iteration limit and convergence behavior
The goal is to clarify how scikit-learn’s iterative estimators signal that the max_iter bound was reached before meeting the tolerance (tol) and whether this signal can be used to halt training gracefully.
When fit exceeds max_iter, a ConvergenceWarning is emitted, but the call remains blocking; there is no built‑in timeout or cancellation flag inside the API. Different solvers (e.g., ‘lbfgs’, ‘sag’, ‘saga’) may produce the warning at different iteration counts or suppress it under certain conditions, which affects how a user perceives a “timeout” versus a failure to converge.
Because the warning can be filtered globally, relying on it for programmatic control may be unreliable, and the lack of an asynchronous interrupt mechanism forces users to manage execution time at the process or OS level.
Technical questions
- How does the timing and frequency of
ConvergenceWarningvary across the supported solvers whenmax_iteris exceeded? - Is there a documented, reliable way to catch this warning inside the same thread and trigger a graceful exit from
fitwithout resorting to external signals? - What are the recommended patterns for enforcing a wall‑clock timeout on scikit‑learn’s blocking
fitcalls while preserving the ability to inspect partial results?