diff --git a/examples/manifold/plot_swissroll.py b/examples/manifold/plot_swissroll.py index 92d4bf4022a019f166e6900bdb329f8535fbfa97..71dfd1c8685cdaf8c3640ac5241d490bf4f3550c 100644 --- a/examples/manifold/plot_swissroll.py +++ b/examples/manifold/plot_swissroll.py @@ -25,7 +25,8 @@ from sklearn import manifold, datasets X, color = datasets.samples_generator.make_swiss_roll(n_samples=1500) print "Computing LLE embedding" -X_r, err = manifold.locally_linear_embedding(X, n_neighbors=12, out_dim=2) +X_r, err = manifold.locally_linear_embedding(X, n_neighbors=12, + n_components=2) print "Done. Reconstruction error: %g" % err #---------------------------------------------------------------------- diff --git a/sklearn/manifold/isomap.py b/sklearn/manifold/isomap.py index dff954215f4a4d4925166690e09e22dfc17c3bd7..9cb9e225e932131c37364f4389d77452ebaf970c 100644 --- a/sklearn/manifold/isomap.py +++ b/sklearn/manifold/isomap.py @@ -80,10 +80,11 @@ class Isomap(BaseEstimator): tol=0, max_iter=None, path_method='auto', neighbors_algorithm='auto', out_dim=None): - if not out_dim is None: + if out_dim: warnings.warn("Parameter ``out_dim`` was renamed to " - "``n_components`` and is now deprecated.", DeprecationWarning) - n_components = n_components + "``n_components`` and is now deprecated.", DeprecationWarning, + stacklevel=2) + self.out_dim = out_dim self.n_neighbors = n_neighbors self.n_components = n_components self.eigen_solver = eigen_solver @@ -95,6 +96,12 @@ class Isomap(BaseEstimator): algorithm=neighbors_algorithm) def _fit_transform(self, X): + if self.out_dim: + warnings.warn("Parameter ``out_dim`` was renamed to " + "``n_components`` and is now deprecated.", DeprecationWarning, + stacklevel=3) + self.n_components = self.out_dim + self.out_dim = None self.nbrs_.fit(X) self.training_data_ = self.nbrs_._fit_X self.kernel_pca_ = KernelPCA(n_components=self.n_components, diff --git a/sklearn/manifold/locally_linear.py b/sklearn/manifold/locally_linear.py index b9529670f437c7a4b3c7e19174f466218a02315d..ebda42af17611b00af31f02a07cd488e618db3e7 100644 --- a/sklearn/manifold/locally_linear.py +++ b/sklearn/manifold/locally_linear.py @@ -272,10 +272,11 @@ def locally_linear_embedding( if method not in ('standard', 'hessian', 'modified', 'ltsa'): raise ValueError("unrecognized method '%s'" % method) - if not out_dim is None: + if out_dim: warnings.warn("Parameter ``out_dim`` was renamed to ``n_components`` " - "and is now deprecated.", DeprecationWarning) - n_components = n_components + "and is now deprecated.", DeprecationWarning, + stacklevel=2) + n_components = out_dim nbrs = NearestNeighbors(n_neighbors=n_neighbors + 1) nbrs.fit(X) @@ -594,10 +595,11 @@ class LocallyLinearEmbedding(BaseEstimator): hessian_tol=1E-4, modified_tol=1E-12, neighbors_algorithm='auto', random_state=None, out_dim=None): - if not out_dim is None: + if out_dim: warnings.warn("Parameter ``out_dim`` was renamed to " - "``n_components`` and is now deprecated.", DeprecationWarning) - n_components = n_components + "``n_components`` and is now deprecated.", DeprecationWarning, + stacklevel=2) + self.out_dim = out_dim self.n_neighbors = n_neighbors self.n_components = n_components @@ -613,6 +615,13 @@ class LocallyLinearEmbedding(BaseEstimator): algorithm=neighbors_algorithm) def _fit_transform(self, X): + if self.out_dim: + warnings.warn("Parameter ``out_dim`` was renamed to " + "``n_components`` and is now deprecated.", DeprecationWarning, + stacklevel=3) + self.n_components = self.out_dim + self.out_dim = None + self.random_state = check_random_state(self.random_state) self.nbrs_.fit(X) self.embedding_, self.reconstruction_error_ = \