RFC try to warn on iid less often#11613
Conversation
|
Fixes #11559 |
Do you mean a general discussion on what should be the tolerance in this case (uncertainty on a scoring for CV) or rather running a benchmark on some particular tasks and based on that make a decision ? |
|
I don't know how to set the tolerance here. I have no idea what the expect difference is. Have you noticed that a given value gives a strong reduction in warnings? |
|
What's the resolution here? We can be conservative and make the tolerance a little smaller, i.e. smaller than anyone tends to report... |
|
So I made some quick benchmark counting the number of warnings raised by iid in the examples (that's what we're trying to reduce, right?). When warning everytime when iid='warn' (different from what is done on master now): With the current changes: Looks like most of the warnings come from Code: Detailsimport importlib
import warnings
import sys
import matplotlib.pyplot as plt
plt.ion() # interactive mode on, prevents matplotlib from blocking
sys.stderr = open('/dev/null', 'w') # hide error messages
examples = [ # list of examples directly using ****SearchCV()
'examples.applications.plot_face_recognition',
'examples.cluster.plot_feature_agglomeration_vs_univariate_selection',
'examples.compose.plot_column_transformer_mixed_types',
'examples.compose.plot_compare_reduction',
'examples.compose.plot_digits_pipe',
'examples.compose.plot_feature_union',
'examples.covariance.plot_covariance_estimation',
'examples.decomposition.plot_pca_vs_fa_model_selection',
'examples.exercises.plot_cv_diabetes',
'examples.gaussian_process.plot_compare_gpr_krr',
'examples.model_selection.grid_search_text_feature_extraction',
'examples.model_selection.plot_grid_search_digits',
'examples.model_selection.plot_multi_metric_evaluation',
'examples.model_selection.plot_nested_cross_validation_iris',
'examples.model_selection.plot_randomized_search',
'examples.neighbors.plot_digits_kde_sampling',
'examples.neural_networks.plot_rbm_logistic_classification',
'examples.plot_kernel_ridge_regression',
'examples.preprocessing.plot_discretization_classification',
'examples.svm.plot_rbf_parameters',
'examples.svm.plot_svm_scale_c',
]
n_iid_warnings = 0
for e in examples:
print('running {}... '.format(e), end='', flush=True)
with warnings.catch_warnings(record=True) as warnings_:
# Cause deprecation warnings to always be triggered.
warnings.simplefilter("always", DeprecationWarning)
sys.stdout = open('/dev/null', 'w') # avoid prints from example exec
importlib.import_module(e)
sys.stdout = sys.__stdout__ # restore the original stdout.
iid_warnings = [w for w in warnings_ if
"The default of the `iid` parameter will change" in
str(w.message)]
print('Got {} iid warnings.'.format(len(iid_warnings)))
n_iid_warnings += len(iid_warnings)
print('Total number of iid warnings: {}'.format(n_iid_warnings))Note: there may be actually more warnings if some of the examples indirectly call one of the CV tools. The list of examples I use comes from I can try different tol values and see which one has the least number of warnings. I just want to make sure this is actually what we want here. Edit: Increasing both tol to |
sklearn/model_selection/_search.py
Outdated
| if not np.allclose(means_weighted, means_unweighted, | ||
| rtol=1e-4, atol=1e-4): | ||
| warn = True | ||
| continue |
|
Is it good to suppresses the deprecation warning? It seems that the common way we handle these problems in this release is to set |
|
The thing is that:
* For many uses this change (iid=t/f) makes negligible difference to the
results
* As the parameter is being deprecated, asking users to set an explicit
value for the parameter means their code will break when the parameter
disappears
* Too many warnings lead to them being ignored
|
|
Maybe to add to @jnothman's excellent explanation: Here we're using the examples code as a proxy for the user's code. I want the users code not to give useless warnings. |
|
So if we're conservative we could do 1e-4 or 1e-5 and we'd get rid of some. If we're more aggressive we can do 1e-3 and get rid of most warnings. |
|
I think 1e-4 is appropriate to what people usually report.
|
|
I think I'm persuaded here. |
|
I'd leave them, otherwise we need to change again soon. |
|
@jnothman rtol or atol? So I'll just leave it as is? |
|
merge for RC? |
|
It would be better to mostly rely on rtol, but I haven't stopped to think about the value. |
qinhanmin2014
left a comment
There was a problem hiding this comment.
LGTM (maybe we can be more aggressive here).
|
Btw @jnothman @amueller How will you handle existing |
|
Well once we deprecate it in 0.22 we'll remove those, right? |
@amueller The issue here is that we don't set |
|
If it's already there I wouldn't worry too much about it. |
* tag '0.20rc1': (1109 commits) MNT rc version DOC Release dates for 0.20 (scikit-learn#11838) DOC Fix: require n_splits > 1 in TimeSeriesSplit (scikit-learn#11937) FIX xfail for MacOS LogisticRegressionCV stability (scikit-learn#11936) MNT: Use GEMV in enet_coordinate_descent (Pt. 1) (scikit-learn#11896) [MRG] TST/FIX stop optics reachability failure on 32bit (scikit-learn#11916) ENH add multi_class='auto' for LogisticRegression, default from 0.22; default solver will be 'lbfgs' (scikit-learn#11905) MAINT Fix test_logistic::test_dtype_match failure on 32 bit arch (scikit-learn#11899) DOC Updated link to Laurens van der Maaten's home page (scikit-learn#11907) DOC Remove stray backtick in /doc/modules/feature_extraction.rst (scikit-learn#11910) Deprecate min_samples_leaf and min_weight_fraction_leaf (scikit-learn#11870) MNT modify test_sparse_oneclasssvm to be parametrized (scikit-learn#11894) EXA set figure size to avoid overlaps (scikit-learn#11889) MRG/REL fixes /skips for 32bit tests (scikit-learn#11879) add durations=20 to makefile to show test runtimes locally (scikit-learn#11147) DOC loss='l2' is no longer accpeted in l1_min_c DOC add note about brute force nearest neighbors for string data (scikit-learn#11884) DOC Change sign of energy in RBM (scikit-learn#11156) RFC try to warn on iid less often (scikit-learn#11613) DOC reduce plot_gpr_prior_posterior.py warnings(scikit-learn#11664) ...
* releases: (1109 commits) MNT rc version DOC Release dates for 0.20 (scikit-learn#11838) DOC Fix: require n_splits > 1 in TimeSeriesSplit (scikit-learn#11937) FIX xfail for MacOS LogisticRegressionCV stability (scikit-learn#11936) MNT: Use GEMV in enet_coordinate_descent (Pt. 1) (scikit-learn#11896) [MRG] TST/FIX stop optics reachability failure on 32bit (scikit-learn#11916) ENH add multi_class='auto' for LogisticRegression, default from 0.22; default solver will be 'lbfgs' (scikit-learn#11905) MAINT Fix test_logistic::test_dtype_match failure on 32 bit arch (scikit-learn#11899) DOC Updated link to Laurens van der Maaten's home page (scikit-learn#11907) DOC Remove stray backtick in /doc/modules/feature_extraction.rst (scikit-learn#11910) Deprecate min_samples_leaf and min_weight_fraction_leaf (scikit-learn#11870) MNT modify test_sparse_oneclasssvm to be parametrized (scikit-learn#11894) EXA set figure size to avoid overlaps (scikit-learn#11889) MRG/REL fixes /skips for 32bit tests (scikit-learn#11879) add durations=20 to makefile to show test runtimes locally (scikit-learn#11147) DOC loss='l2' is no longer accpeted in l1_min_c DOC add note about brute force nearest neighbors for string data (scikit-learn#11884) DOC Change sign of energy in RBM (scikit-learn#11156) RFC try to warn on iid less often (scikit-learn#11613) DOC reduce plot_gpr_prior_posterior.py warnings(scikit-learn#11664) ...
* dfsg: (1109 commits) MNT rc version DOC Release dates for 0.20 (scikit-learn#11838) DOC Fix: require n_splits > 1 in TimeSeriesSplit (scikit-learn#11937) FIX xfail for MacOS LogisticRegressionCV stability (scikit-learn#11936) MNT: Use GEMV in enet_coordinate_descent (Pt. 1) (scikit-learn#11896) [MRG] TST/FIX stop optics reachability failure on 32bit (scikit-learn#11916) ENH add multi_class='auto' for LogisticRegression, default from 0.22; default solver will be 'lbfgs' (scikit-learn#11905) MAINT Fix test_logistic::test_dtype_match failure on 32 bit arch (scikit-learn#11899) DOC Updated link to Laurens van der Maaten's home page (scikit-learn#11907) DOC Remove stray backtick in /doc/modules/feature_extraction.rst (scikit-learn#11910) Deprecate min_samples_leaf and min_weight_fraction_leaf (scikit-learn#11870) MNT modify test_sparse_oneclasssvm to be parametrized (scikit-learn#11894) EXA set figure size to avoid overlaps (scikit-learn#11889) MRG/REL fixes /skips for 32bit tests (scikit-learn#11879) add durations=20 to makefile to show test runtimes locally (scikit-learn#11147) DOC loss='l2' is no longer accpeted in l1_min_c DOC add note about brute force nearest neighbors for string data (scikit-learn#11884) DOC Change sign of energy in RBM (scikit-learn#11156) RFC try to warn on iid less often (scikit-learn#11613) DOC reduce plot_gpr_prior_posterior.py warnings(scikit-learn#11664) ...
This suppresses the iid warning more often. But then the question is what are good tolerances for allclose?
Fixes #11559