Skip to content

Commit ba7e6fb

Browse files
authored
DOC Ensures that TruncatedSVD passes numpydoc validation (scikit-learn#20946)
1 parent a122ad7 commit ba7e6fb

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

maint_tools/test_docstrings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
"StackingRegressor",
8585
"TheilSenRegressor",
8686
"TransformedTargetRegressor",
87-
"TruncatedSVD",
8887
"TweedieRegressor",
8988
"VarianceThreshold",
9089
]

sklearn/decomposition/_truncated_svd.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class TruncatedSVD(TransformerMixin, BaseEstimator):
6464
multiple function calls.
6565
See :term:`Glossary <random_state>`.
6666
67-
tol : float, default=0.
67+
tol : float, default=0.0
6868
Tolerance for ARPACK. 0 means machine precision. Ignored by randomized
6969
SVD solver.
7070
@@ -96,6 +96,29 @@ class TruncatedSVD(TransformerMixin, BaseEstimator):
9696
9797
.. versionadded:: 1.0
9898
99+
See Also
100+
--------
101+
DictionaryLearning : Find a dictionary that sparsely encodes data.
102+
FactorAnalysis : A simple linear generative model with
103+
Gaussian latent variables.
104+
IncrementalPCA : Incremental principal components analysis.
105+
KernelPCA : Kernel Principal component analysis.
106+
NMF : Non-Negative Matrix Factorization.
107+
PCA : Principal component analysis.
108+
109+
Notes
110+
-----
111+
SVD suffers from a problem called "sign indeterminacy", which means the
112+
sign of the ``components_`` and the output from transform depend on the
113+
algorithm and random state. To work around this, fit instances of this
114+
class to data once, then keep the instance around to do transformations.
115+
116+
References
117+
----------
118+
Finding structure with randomness: Stochastic algorithms for constructing
119+
approximate matrix decompositions
120+
Halko, et al., 2009 (arXiv:909) https://arxiv.org/pdf/0909.4061.pdf
121+
99122
Examples
100123
--------
101124
>>> from sklearn.decomposition import TruncatedSVD
@@ -114,23 +137,6 @@ class TruncatedSVD(TransformerMixin, BaseEstimator):
114137
0.2102...
115138
>>> print(svd.singular_values_)
116139
[35.2410... 4.5981... 4.5420... 4.4486... 4.3288...]
117-
118-
See Also
119-
--------
120-
PCA
121-
122-
References
123-
----------
124-
Finding structure with randomness: Stochastic algorithms for constructing
125-
approximate matrix decompositions
126-
Halko, et al., 2009 (arXiv:909) https://arxiv.org/pdf/0909.4061.pdf
127-
128-
Notes
129-
-----
130-
SVD suffers from a problem called "sign indeterminacy", which means the
131-
sign of the ``components_`` and the output from transform depend on the
132-
algorithm and random state. To work around this, fit instances of this
133-
class to data once, then keep the instance around to do transformations.
134140
"""
135141

136142
def __init__(
@@ -157,6 +163,7 @@ def fit(self, X, y=None):
157163
Training data.
158164
159165
y : Ignored
166+
Not used, present here for API consistency by convention.
160167
161168
Returns
162169
-------
@@ -175,6 +182,7 @@ def fit_transform(self, X, y=None):
175182
Training data.
176183
177184
y : Ignored
185+
Not used, present here for API consistency by convention.
178186
179187
Returns
180188
-------

0 commit comments

Comments
 (0)