-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
ENH add n_jobs to mutual_info_regression and mutual_info_classif #28085
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
Changes from all commits
02d995b
d9a1886
e27f6db
d215fea
e1a7f59
152dfa5
28a229b
d1ff120
ad2884d
7912c96
10d1e51
354a63e
abe0351
2f1d67f
9255f36
71b974a
fa5ba80
68871a2
5a54c2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
from sklearn.datasets import make_classification, make_regression | ||
from sklearn.feature_selection import mutual_info_classif, mutual_info_regression | ||
from sklearn.feature_selection._mutual_info import _compute_mi | ||
from sklearn.utils import check_random_state | ||
|
@@ -252,3 +253,18 @@ def test_mutual_info_regression_X_int_dtype(global_random_seed): | |
expected = mutual_info_regression(X_float, y, random_state=global_random_seed) | ||
result = mutual_info_regression(X, y, random_state=global_random_seed) | ||
assert_allclose(result, expected) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @netomenoci I push a piece of code that show how to make the parallelization if you are interested in. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. awesome, thanks :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi bary Wery good nice good luck bary |
||
"mutual_info_func, data_generator", | ||
[ | ||
(mutual_info_regression, make_regression), | ||
(mutual_info_classif, make_classification), | ||
], | ||
) | ||
def test_mutual_info_n_jobs(global_random_seed, mutual_info_func, data_generator): | ||
"""Check that results are consistent with different `n_jobs`.""" | ||
X, y = data_generator(random_state=global_random_seed) | ||
single_job = mutual_info_func(X, y, random_state=global_random_seed, n_jobs=1) | ||
multi_job = mutual_info_func(X, y, random_state=global_random_seed, n_jobs=2) | ||
assert_allclose(single_job, multi_job) |
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.
I used keyword arguments to make the code more readable in the
_estimate_mi
function call and also use keyword-only arguments in the_estimate_mi
definition.I guess that's fine since
_estimate_mi
is private. @glemaitre do you agree?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.
Yes I do agree.