-
Notifications
You must be signed in to change notification settings - Fork 0
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
Parallelization #9
Conversation
:return: The metrics of the population. | ||
""" | ||
if self.n_jobs != 1: | ||
num_jobs = self.n_jobs if self.n_jobs != -1 else len(population) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use 1 thread per candidate if we enter -1 for n_jobs
pop_results = self.evaluate_subset(pop_subset, verbose=verbose) | ||
for candidate, metrics in zip(pop_subset, pop_results): | ||
candidate.metrics = metrics | ||
candidate.outcomes = self.outcomes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
evaluate_population
is now solely responsible for selecting the correct candidates to evaluate then setting their metrics. The meat of the work is done in the bottom-level functions which get delegated to by evaluate_subset
TODO: Make parallel_evaluation take in force argument and handle evaluating a subset of the population in | ||
parallel. | ||
""" | ||
parallel_results = Parallel(n_jobs=n_jobs)(delayed(self.evaluate_candidate)(cand) for cand in population) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uses the simple joblib convention for parallelization
val_metrics = self.validator.evaluate_candidate(candidate) | ||
|
||
# Get validation results manually without setting cand's metrics or outcomes | ||
valid_results = self.validator.evaluate_subset(self.population, verbose=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that the code is refactored to have a function that takes in a population and returns the metrics without setting them, validation is much cleaner
Added parallel functions into the evaluator as well as a unit test to help verify