Skip to content

Benchmark Early Stopping for the GapEncoder #663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from

Conversation

simonamaggio
Copy link

@simonamaggio simonamaggio commented Jul 20, 2023

This PR adds a script to benchmark the use of early stopping for GapEncoder.
The early stopping, implemented in a modified version of GapEncoder and enabled with early_stop=True, monitors the GapEncoder score every monitor_steps batches. As soon as the score increases (worsen) it triggers a counter with a limit given by patience batches. If after patience batches the score has not been decreased, the process is ended.

This PR is related to #593, where a previous benchmark is run to investigate GAPEncoder slowness.

@simonamaggio
Copy link
Author

Results of the comparison for a small dataset in skrub: employee_salaries:
Screenshot 2023-07-20 at 16 07 39

@simonamaggio
Copy link
Author

simonamaggio commented Jul 20, 2023

Remarks:

  • Should we add an early stopping to the GapEncoder class directly and modify the bench script ?
  • Should we add the min_delta parameter (like in pytorch), i.e. a decrease of more than or equal to min_delta, will count as improvement? For now there's no such parameter, so equivalent to min_delta=0.
  • Should we record the best encoder status so far (score, matrices, ...) so to restore it in case the score worsen instead? Here we always take the last score obtained.
  • The outer stopping tol should still be tuned to higher values according to Benchmark GapEncoder divergence #593 results.

@simonamaggio simonamaggio changed the title Add Early Stopping to GapEncoder Benchmark Early Stopping for the GapEncoder Jul 20, 2023
@LeoGrin
Copy link
Contributor

LeoGrin commented Jul 20, 2023

Should we record the best encoder status so far (score, matrices, ...) so to restore it in case the score worsen instead? Here we always take the last score obtained.

I think taking the last should be okay, though we can check when I run the benchmarks on more datasets. (also it decreases the memory usage).

Should we add the min_delta parameter (like in pytorch), i.e. a decrease of more than or equal to min_delta, will count as improvement? For now there's no such parameter, so equivalent to min_delta=0.

I think this would be useful! (I'll do it)

@LeoGrin LeoGrin added the benchmarks Something related to the benchmarks label Jul 21, 2023
@simonamaggio
Copy link
Author

simonamaggio commented Jul 21, 2023

Here is the updated result for commit 785082e

Screenshot 2023-07-21 at 15 50 59

@LeoGrin
Copy link
Contributor

LeoGrin commented Jul 26, 2023

Right now the version with early stopping is actually slower than the original version, I think because the score method is so long. I'll try to see if it can be sped up.

@LeoGrin
Copy link
Contributor

LeoGrin commented Aug 18, 2023

See #681

@LeoGrin LeoGrin closed this Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
benchmarks Something related to the benchmarks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants