8000 Add comment about ignore_warnings · scikit-learn/scikit-learn@38561e1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 38561e1

Browse files
committed
Add comment about ignore_warnings
1 parent 4bb09ea commit 38561e1

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

benchmarks/bench_plot_nmf.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from sklearn.decomposition.nmf import _initialize_nmf
2020
from sklearn.decomposition.nmf import _safe_compute_error
2121
from sklearn.externals.joblib import Memory
22+
from sklearn.exceptions import ConvergenceWarning
2223

2324
mem = Memory(cachedir='.', verbose=0)
2425

@@ -90,7 +91,6 @@ def multiplicative_nmf(X, W, H, n_iter=100, alpha=0., l1_ratio=0.):
9091
return W, H
9192

9293

93-
@ignore_warnings
9494
def plot_results(results_df, plot_name):
9595
if results_df is None:
9696
return None
@@ -102,9 +102,9 @@ def plot_results(results_df, plot_name):
102102
for i, init in enumerate(np.unique(results_df['init'])):
103103
plt.subplot(1, 3, i + 1, sharex=ax, sharey=ax)
104104
for j, method in enumerate(np.unique(results_df['method'])):
105-
selected_items = (results_df
106-
[results_df['init'] == init]
107-
[results_df['method'] == method])
105+
mask = np.logical_and(results_df['init'] == init,
106+
results_df['method'] == method)
107+
selected_items = results_df[mask]
108108

109109
plt.plot(selected_items['time'], selected_items['loss'],
110110
color=colors[j % len(colors)], ls='-',
@@ -118,9 +118,12 @@ def plot_results(results_df, plot_name):
118118
plt.suptitle(plot_name, fontsize=16)
119119

120120

121-
# use joblib to cache results.
121+
# The deprecated projected-gradient solver raises a UserWarning as convergence
122+
# is not reached; the coordinate-descent solver raises a ConvergenceWarning.
123+
@ignore_warnings(category=(ConvergenceWarning, UserWarning,
124+
DeprecationWarning))
125+
# use joblib to cache the results.
122126
# X_shape is specified in arguments for avoiding hashing X
123-
@ignore_warnings
124127
@mem.cache(ignore=['X', 'W0', 'H0'])
125128
def bench_one(name, X, W0, H0, X_shape, clf_type, clf_params, init,
126129
n_components, random_state):

0 commit comments

Comments
 (0)
0