@@ -831,6 +831,20 @@ class MaxAbsScaler(BaseEstimator, TransformerMixin):
831
831
The number of samples processed by the estimator. Will be reset on
832
832
new calls to fit, but increments across ``partial_fit`` calls.
833
833
834
+ Examples
835
+ --------
836
+ >>> from sklearn.preprocessing import MaxAbsScaler
837
+ >>> X = [[ 1., -1., 2.],
838
+ ... [ 2., 0., 0.],
839
+ ... [ 0., 1., -1.]]
840
+ >>> transformer = MaxAbsScaler().fit(X)
841
+ >>> transformer
842
+ MaxAbsScaler(copy=True)
843
+ >>> transformer.transform(X)
844
+ array([[ 0.5, -1. , 1. ],
845
+ [ 1. , 0. , 0. ],
846
+ [ 0. , 1. , -0.5]])
847
+
834
848
See also
835
849
--------
836
850
maxabs_scale: Equivalent function without the estimator API.
@@ -1068,6 +1082,21 @@ class RobustScaler(BaseEstimator, TransformerMixin):
1068
1082
.. versionadded:: 0.17
1069
1083
*scale_* attribute.
1070
1084
1085
+ Examples
1086
+ --------
1087
+ >>> from sklearn.preprocessing import RobustScaler
1088
+ >>> X = [[ 1., -2., 2.],
1089
+ ... [ -2., 1., 3.],
1090
+ ... [ 4., 1., -2.]]
1091
+ >>> transformer = RobustScaler().fit(X)
1092
+ >>> transformer
1093
+ RobustScaler(copy=True, quantile_range=(25.0, 75.0), with_centering=True,
1094
+ with_scaling=True)
1095
+ >>> transformer.transform(X)
1096
+ array([[ 0. , -2. , 0. ],
1097
+ [-1. , 0. , 0.4],
1098
+ [ 1. , 0. , -1.6]])
1099
+
1071
1100
See also
1072
1101
--------
1073
1102
robust_scale: Equivalent function without the estimator API.
@@ -1580,6 +1609,20 @@ class Normalizer(BaseEstimator, TransformerMixin):
1580
1609
copy (if the input is already a numpy array or a scipy.sparse
1581
1610
CSR matrix).
1582
1611
1612
+ Examples
1613
+ --------
1614
+ >>> from sklearn.preprocessing import Normalizer
1615
+ >>> X = [[4, 1, 2, 2],
1616
+ ... [1, 3, 9, 3],
1617
+ ... [5, 7, 5, 1]]
1618
+ >>> transformer = Normalizer().fit(X) # fit does nothing.
1619
+ >>> transformer
1620
+ Normalizer(copy=True, norm='l2')
1621
+ >>> transformer.transform(X)
1622
+ array([[0.8, 0.2, 0.4, 0.4],
1623
+ [0.1, 0.3, 0.9, 0.3],
1624
+ [0.5, 0.7, 0.5, 0.1]])
1625
+
1583
1626
Notes
1584
1627
-----
1585
1628
This estimator is stateless (besides constructor parameters), the
@@ -1707,6 +1750,20 @@ class Binarizer(BaseEstimator, TransformerMixin):
1707
1750
set to False to perform inplace binarization and avoid a copy (if
1708
1751
the input is already a numpy array or a scipy.sparse CSR matrix).
1709
1752
1753
+ Examples
1754
+ --------
1755
+ >>> from sklearn.preprocessing import Binarizer
1756
+ >>> X = [[ 1., -1., 2.],
1757
+ ... [ 2., 0., 0.],
1758
+ ... [ 0., 1., -1.]]
1759
+ >>> transformer = Binarizer().fit(X) # fit does nothing.
1760
+ >>> transformer
1761
+ Binarizer(copy=True, threshold=0.0)
1762
+ >>> transformer.transform(X)
1763
+ array([[1., 0., 1.],
1764
+ [1., 0., 0.],
1765
+ [0., 1., 0.]])
1766
+
1710
1767
Notes
1711
1768
-----
1712
1769
If the input is a sparse matrix, only the non-zero values are subject
@@ -1771,7 +1828,28 @@ class KernelCenterer(BaseEstimator, TransformerMixin):
1771
1828
sklearn.preprocessing.StandardScaler(with_std=False).
1772
1829
1773
1830
Read more in the :ref:`User Guide <kernel_centering>`.
1831
+
1832
+ Examples
1833
+ --------
1834
+ >>> from sklearn.preprocessing import KernelCenterer
1835
+ >>> from sklearn.metrics.pairwise import pairwise_kernels
1836
+ >>> X = [[ 1., -2., 2.],
1837
+ ... [ -2., 1., 3.],
1838
+ ... [ 4., 1., -2.]]
1839
+ >>> K = pairwise_kernels(X, metric='linear')
1840
+ >>> K
1841
+ array([[ 9., 2., -2.],
1842
+ [ 2., 14., -13.],
1843
+ [ -2., -13., 21.]])
1844
+ >>> transformer = KernelCenterer().fit(K)
1845
+ >>> transformer
1846
+ KernelCenterer()
1847
+ >>> transformer.transform(K)
1848
+ array([[ 5., 0., -5.],
1849
+ [ 0., 14., -14.],
1850
+ [ -5., -14., 19.]])
1774
1851
"""
1852
+
1775
1853
def __init__ (self ):
1776
1854
# Needed for backported inspect.signature compatibility with PyPy
1777
1855
pass
0 commit comments