Skip to content
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

specify number of parallel jobs for CrossvalMultipleRegularizations #39

Merged
merged 1 commit into from
Nov 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions pysaliency/baseline_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,17 @@ def _normalize_regularization_factors(args):


class CrossvalMultipleRegularizations(object):
""" Class for computing crossvalidation scores of a fixation KDE with multiple regularization models"""
def __init__(self, stimuli, fixations, regularization_models: OrderedDict, crossvalidation, verbose=False):
"""Class for computing crossvalidation scores of a fixation KDE with multiple regularization models

n_jobs: number of parallel jobs to use in cross_val_score
verbose: verbosity level for cross_val_score
"""
def __init__(self, stimuli, fixations, regularization_models: OrderedDict, crossvalidation, n_jobs=None, verbose=False):
self.stimuli = stimuli
self.fixations = fixations

self.cv = crossvalidation
self.n_jobs = n_jobs
self.verbose = verbose

X_areas = fixations_to_scikit_learn(
Expand Down Expand Up @@ -413,13 +418,13 @@ def score(self, log_bandwidth, *args, **kwargs):


class CrossvalGoldMultipleRegularizations(CrossvalMultipleRegularizations):
def __init__(self, stimuli, fixations, regularization_models, verbose=False):
def __init__(self, stimuli, fixations, regularization_models, n_jobs=None, verbose=False):
if fixations.subject_count > 1:
crossvalidation_factory = ScikitLearnImageSubjectCrossValidationGenerator
else:
crossvalidation_factory = ScikitLearnWithinImageCrossValidationGenerator

super().__init__(stimuli, fixations, regularization_models, crossvalidation_factory=crossvalidation_factory, verbose=verbose)
super().__init__(stimuli, fixations, regularization_models, crossvalidation_factory=crossvalidation_factory, n_jobs=n_jobs, verbose=verbose)


# baseline models
Expand Down
Loading