Skip to content

Commit 3269e6c

Browse files
committed
ENH add deprecation for projected gradient
1 parent a8393e8 commit 3269e6c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

sklearn/decomposition/nmf.py

+4
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,8 @@ def non_negative_matrix_factorization(X, W=None, H=None, n_components=None,
706706
random_state=random_state)
707707

708708
if solver == 'proj-grad':
709+
warnings.warn("'proj-grad' solver will be removed in release 0.19."
710+
" Use 'coordinate' solver instead.", DeprecationWarning)
709711
if update_H: # fit_transform
710712
W, H, n_iter = _fit_projected_gradient(X, W, H, tol,
711713
max_iter,
@@ -946,6 +948,8 @@ def transform(self, X):
946948
return W
947949

948950

951+
@deprecated("It will be removed in release 0.19. Use NMF instead."
952+
"'proj-grad' solver is still available until release 0.19.")
949953
class ProjectedGradientNMF(NMF):
950954
__doc__ = NMF.__doc__
951955

sklearn/decomposition/tests/test_nmf.py

+8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def test_initialize_nn_output():
2323
assert_false((W < 0).any() or (H < 0).any())
2424

2525

26+
@ignore_warnings
2627
def test_parameter_checking():
2728
A = np.ones((2, 2))
2829
name = 'spam'
@@ -65,6 +66,7 @@ def test_initialize_variants():
6566
assert_true(np.allclose(evl[ref != 0], ref[ref != 0]))
6667

6768

69+
@ignore_warnings
6870
def test_nmf_fit_nn_output():
6971
# Test that the decomposition does not contain negative values
7072
A = np.c_[5 * np.ones(5) - np.arange(1, 6),
@@ -78,6 +80,7 @@ def test_nmf_fit_nn_output():
7880
(transf < 0).any())
7981

8082

83+
@ignore_warnings
8184
def test_nmf_fit_close():
8285
# Test that the fit is not too far away
8386
for solver in ('proj-grad', 'coordinate'):
@@ -101,6 +104,7 @@ def test_nls_close():
101104
assert_true((np.abs(Ap - A) < 0.01).all())
102105

103106

107+
@ignore_warnings
104108
def test_nmf_transform():
105109
# Test that NMF.transform returns close values
106110
A = np.abs(random_state.randn(6, 5))
@@ -139,6 +143,7 @@ def test_nmf_sparseness():
139143
assert_greater(comp_sp, m.comp_sparseness_)
140144

141145

146+
@ignore_warnings
142147
def test_sparse_input():
143148
# Test that sparse matrices are accepted as input
144149
from scipy.sparse import csc_matrix
@@ -164,6 +169,7 @@ def test_sparse_input():
164169
assert_array_almost_equal(H1, H2)
165170

166171

172+
@ignore_warnings
167173
def test_sparse_transform():
168174
# Test that transform works on sparse data. Issue #2124
169175
from scipy.sparse import csc_matrix
@@ -179,6 +185,7 @@ def test_sparse_transform():
179185
assert_array_almost_equal(A_fit_tr, A_tr, decimal=2)
180186

181187

188+
@ignore_warnings
182189
def test_non_negative_matrix_factorization_path():
183190
# Test path consistency between the class and the public function
184191
A = np.abs(random_state.randn(10, 10))
@@ -197,6 +204,7 @@ def test_non_negative_matrix_factorization_path():
197204
assert_array_almost_equal(W_nmf_bis, W_cls_bis, decimal=10)
198205

199206

207+
@ignore_warnings
200208
def test_non_negative_matrix_factorization_checking():
201209
A = np.ones((2, 2))
202210
# Test parameters checking is public function

0 commit comments

Comments
 (0)