Skip to content

DOC Fixes numpydoc validation errors in StandardScalar #20368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion maint_tools/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@
"SplineTransformer",
"StackingClassifier",
"StackingRegressor",
"StandardScaler",
"TSNE",
"TfidfTransformer",
"TfidfVectorizer",
Expand Down
40 changes: 20 additions & 20 deletions sklearn/preprocessing/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ def minmax_scale(X, feature_range=(0, 1), *, axis=0, copy=True):


class StandardScaler(TransformerMixin, BaseEstimator):
"""Standardize features by removing the mean and scaling to unit variance
"""Standardize features by removing the mean and scaling to unit variance.

The standard score of a sample `x` is calculated as:

Expand Down Expand Up @@ -712,23 +712,6 @@ class StandardScaler(TransformerMixin, BaseEstimator):
Will be reset on new calls to fit, but increments across
``partial_fit`` calls.

Examples
--------
>>> from sklearn.preprocessing import StandardScaler
>>> data = [[0, 0], [0, 0], [1, 1], [1, 1]]
>>> scaler = StandardScaler()
>>> print(scaler.fit(data))
StandardScaler()
>>> print(scaler.mean_)
[0.5 0.5]
>>> print(scaler.transform(data))
[[-1. -1.]
[-1. -1.]
[ 1. 1.]
[ 1. 1.]]
>>> print(scaler.transform([[2, 2]]))
[[3. 3.]]

See Also
--------
scale : Equivalent function without the estimator API.
Expand All @@ -748,6 +731,23 @@ class StandardScaler(TransformerMixin, BaseEstimator):
For a comparison of the different scalers, transformers, and normalizers,
see :ref:`examples/preprocessing/plot_all_scaling.py
<sphx_glr_auto_examples_preprocessing_plot_all_scaling.py>`.

Examples
--------
>>> from sklearn.preprocessing import StandardScaler
>>> data = [[0, 0], [0, 0], [1, 1], [1, 1]]
>>> scaler = StandardScaler()
>>> print(scaler.fit(data))
StandardScaler()
>>> print(scaler.mean_)
[0.5 0.5]
>>> print(scaler.transform(data))
[[-1. -1.]
[-1. -1.]
[ 1. 1.]
[ 1. 1.]]
>>> print(scaler.transform([[2, 2]]))
[[3. 3.]]
""" # noqa

def __init__(self, *, copy=True, with_mean=True, with_std=True):
Expand Down Expand Up @@ -946,7 +946,7 @@ def partial_fit(self, X, y=None, sample_weight=None):
return self

def transform(self, X, copy=None):
"""Perform standardization by centering and scaling
"""Perform standardization by centering and scaling.

Parameters
----------
Expand Down Expand Up @@ -989,7 +989,7 @@ def transform(self, X, copy=None):
return X

def inverse_transform(self, X, copy=None):
"""Scale back the data to the original representation
"""Scale back the data to the original representation.

Parameters
----------
Expand Down