19
19
from sklearn .decomposition .nmf import _initialize_nmf
20
20
from sklearn .decomposition .nmf import _safe_compute_error
21
21
from sklearn .externals .joblib import Memory
22
+ from sklearn .exceptions import ConvergenceWarning
22
23
23
24
mem = Memory (cachedir = '.' , verbose = 0 )
24
25
@@ -90,7 +91,6 @@ def multiplicative_nmf(X, W, H, n_iter=100, alpha=0., l1_ratio=0.):
90
91
return W , H
91
92
92
93
93
- @ignore_warnings
94
94
def plot_results (results_df , plot_name ):
95
95
if results_df is None :
96
96
return None
@@ -102,9 +102,9 @@ def plot_results(results_df, plot_name):
102
102
for i , init in enumerate (np .unique (results_df ['init' ])):
103
103
plt .subplot (1 , 3 , i + 1 , sharex = ax , sharey = ax )
104
104
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 ]
108
108
109
109
plt .plot (selected_items ['time' ], selected_items ['loss' ],
110
110
color = colors [j % len (colors )], ls = '-' ,
@@ -118,9 +118,12 @@ def plot_results(results_df, plot_name):
118
118
plt .suptitle (plot_name , fontsize = 16 )
119
119
120
120
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.
122
126
# X_shape is specified in arguments for avoiding hashing X
123
- @ignore_warnings
124
127
@mem .cache (ignore = ['X' , 'W0' , 'H0' ])
125
128
def bench_one (name , X , W0 , H0 , X_shape , clf_type , clf_params , init ,
126
129
n_components , random_state ):
0 commit comments